Basic java Program and details of it.

Simple Program:

 

Class FirstJavaProgram

{

Public static void main(String args[])

{

System.out.println(“This is my First Program”);

}

}

 

For saving the Java application –      FirstJavaProgram.java

For compilation –                                javac FirstJavaProgram.java

For execution-                                                java FirstJavaProgram

 

Programming Basics:

public static void main(String args[ ])

public : access specifier

static : type of method

void :  return type of main()

static means it will be loaded to main memory when class is loaded

String args [ ] : String  array

{Note: – args is default name; we can change it as per the requirement}

String aa[ ] & String [ ] args is also correct.

 

We have System.out.println(); method

System- It is class present in java.lang Package.

i.e.:

public final class System

{

static PrintStream out;

}

 

PrintStream class hasthe following overloaded insatance methods:

print(byte);

print(short);

print(int);

print(float);

print(long);

print(double);

print(char);

print(boolean);

print(String);

similarly, in this class, 9 println() methods are available.

Leave a Reply

Your email address will not be published. Required fields are marked *