‹‹ Previous
Next ››
Java Introduction
is platform independent programming language.
Java creates a bytecode that can be run on any type of machine with the help of
Java Virtual Machine (JVM).
Java is secure language because java is not using pointers.
Java is also called "write once and run anywhere" programming language.
First Java Program
- Java program can be written in Notepad or any text editor.
- Java program starts by creating a class.
Example
class FirstJavaProg {
public static void main (String args[])
{
System.out.println ("Hello ! Dear learner");
}
}
Output of the program
Hello ! Dear learner
Explanation of the program
- A class named FirstJavaProg is created.
- A java program starts from main() method. Hence, main() method is created in the class.
- Main() method must be defined as public static void and must receives array of arguments of String type .
- To display a message, the statement System.out.println() is used.
- Class and main() method are properly closed by curly brackets.
Compiling Java Program
Running Java Program
- Java program is run by using the command 'java'. Remember do not include .java extension.
java FirstJavaProg
‹‹ Previous
Next ››