Java Concepts
The best way to learn a new language is to write a few simple example programs and execute them. We begins with a very simple program that prints a line of text as output.
class SampleOne
{
public static void main(String args[])
{
System.out.print(“Java is better than C++.”)
}
}
Class Declaration
The first line
Opening Brace
Every class definition in java begin with an opening brace " { " and with an matching closing brace " } ", appearing in the last line of example. This is similar to C++ class construct.
The Main Line
The third line
The line contains a number of keywords, public, static, and void.
| public | The keyword public is an access specifies that declares the main method as unprotected and therefore making it accessible to all other classes. This is similar to the C++ public modifier |
| static | Next appears the keyword static, which declares this method as one that belongs to the entire class and not a part of any objects of the class. The main must always be declared as static since the interpreter uses this method before any objects are created. |
| void | The type modifier void states that the main method does not return any value. |
The Output Line
The only executable statement in program is
This is similar to the printf() statement in C or cout<< construct of C++. Since Java is an Object Oriented language, every method must be part of an object. The println method is a member of the out object, which is a static data member of system class. This line prints the string.

