Download Free English Song Albums Here

Thursday

Create Program in JAVA

Create First Program In Java:

In this section, you will learn to write a simple Java program. For developing a java program you just need  a simple text editor like "notepad".
Open the notepad and write your program.
Let's create a class createfirstprogram that will print a message "Welcome to javaenvironment.blogspot.com" on the console.

Here is the code of createfirstprogram.java file:

class createfirstprogram{
  public static void main(String[] args) {
  System.out.println("Welcome to javaenvironment.blogspot.com");
  }
}


Save this program in the specified directory ("C:\Vinod" in this example) with name createfirstprogram.java.


This class contains  public, static and void java keywords (these are pre-defined words in java which carries specific meaning).

public keyword specifies the accessibility issues of a class. Here, It specifies that method can be accessed from anywhere.

static keyword  indicates that this method can be invoked simply by using the name of the class without creating any class-object.

void keyword specifies that this method will not return any type of data.

main() method is the main entry point of the program, to start execution. First of all JVM calls the main method of a class and start execution .  JVM (Java Virtual Machine) is responsible for running java programs.

args is a string array that takes values from java command line. It's index starts from '0'. We can access values by writing args[0], args[1] etc.

println() function prints the output to the standard output stream (monitor).

out
represents the standard output stream (monitor).

Now, you are ready to compile and run this program. Open the command prompt and go to the directory ("C:\vinod" in this example) where your program is saved.
Java uses the "javac" command to compile your program (Type javac createfirstprogram.java) . After compiling successfully, you can run it. Java uses the "java" command to execute your program (Type java createfirstprogram). It will print  "Welcome to javaenvironment.blogspot.com".

Output of program: 

C:\faiz>javac createfirstprogram.java

C:\faiz>java createfirstprogram
Welcome to javaenvironment.blogspot.com

C:\vinod>_



Related Post:

No comments:

Post a Comment

More Posts

Justin Bieber Albums Download - Under the Mistletoe 2011 Justin Bieber feat. Usher - The Christmas Song Justin bieber 2011 New Album And Top Songs Justin Bieber Albums - Never Say Never - The Remixes 2011 Justin bieber Albums - Justin Bieber - My Worlds The Collection (Acoustic) 2010 Justin Bieber Songs - My world 2.0 (2010) - Justin Bieber - Mp3.320 kbps.VBR - Inc Covers & bonus tracks -Mediafire
Justin Bieber Albums Download - Under the Mistletoe 2011 Justin Bieber feat. Usher - The Christmas Song Justin bieber 2011 New Album And Top Songs Justin Bieber Albums - Never Say Never - The Remixes 2011 Justin bieber Albums - Justin Bieber - My Worlds The Collection (Acoustic) 2010 Justin Bieber Songs - My world 2.0 (2010) - Justin Bieber - Mp3.320 kbps.VBR - Inc Covers & bonus tracks -Mediafire
50 Cent Albums Download (8) Akon Albums Download (11) Albums Released This November (17) Albums Released This October (24) Ashley Tisdale Albums Download (2) Avril Lavigne Albums Download (4)
+ Grab this