Important points to remember in JAVA:


·         Function main is the entry point of a java program.
·         Function main is a member of the class.
·         Every class MAY have at most one main function. There may be more than one main function in a Java program, however.
·         The main function must be public static void.
·         The main must have only one argument: an array of String. This array contains the command-line arguments.
·         There is no final semi-colon at the end of the class definition.
Compiling a Java Program File:
We assume that you have downloaded and installed the latest version of JDK (Java Development Kit) from:
http://www.oracle.com/technetwork/java/javase/downloads/index.html

After the installation of JDK, you need to add the bin directory of your java installation to the system path variable, so that the system could find the java compiler and interpreter, whenever needed.
·         When compiling a program, you type the full file name, including the ".java" extension and when running a program, you just type the name of the class whose main function you want to execute.
·         Use javac command to compile your java program files.
C:\ javac helloworld.java

Use java command to run or execute the compiler generated .class files.
C:\ java helloworld

Note that your directory structure may be different from the above.
·         Java has two "categories" of types: primitive types and reference types.

Primitive Types
Primitive data types are generally used for local variables, parameters and instance variables (properties of an object). Primitive data types are located on the stack and we can only access their value, while objects are located on heap and we have a reference to those objects. Also, when invoking methods in java, primitive data types are always passed by value and objects are always passed by reference. All the primitive types have specified sizes that are machine independent for portability. 
 

boolean
same as bool in C++
1 byte in size
char
holds one 16 bit unicode character
2 bytes in size
byte
8-bit signed integer
1 byte in size
short
16-bit signed integer
2 bytes in size
into
32-bit signed integer
4 bytes in size
long
64-bit signed integer
8 bytes in size
float
floating-point number
4 bytes in size
double
double precision floating-point number
8 bytes in size

Reference Types
Arrays and objects of classes are the examples of Java reference types. Arrays and classes are discussed in the coming lessons. There are no struct, union, enum, unsigned, typedef, or pointer types in Java.