Java First Program

/**
*Hello World, first application, only output.
*/
import java.io.*;
public class hello{
public static void main (String [] args) {
System.out.println(“Hello World\n”);
} //end main
} //end class

Running the Program
• Text in hello.java file
– Why?
• To compile:
– javac hello.java
• To run:
– java hello 

Comments
• /* This kind of comment can span multiple
lines */
• // This kind is to the end of the line
• /**
* This kind of comment is a special
* ‘javadoc’ style comment
*/ 

Package
• import java.io.*;
– To import packages
– “all” inside “io” package inside “java” package 

The Program:-
public class hello{ … }
– A public Class named “hello”
public static void main (String [] args) { … }
– The main() function
System.out.println(“Hello World\n”);
– Print line statement to print “Hello World” 

Primitive Data Types


Related Posts