<aside> <img src="/icons/table_red.svg" alt="/icons/table_red.svg" width="40px" /> Table of Contents
</aside>
<aside> 💡
<aside> 💡
Java program is an object-oriented programming language, that means java is the collection of objects, and these objects communicate through method calls to each other to work together. Below is the brief overview on the Classes and Objects , Method , Instance variables , syntax, and semantics of Java.
Class: The class is a blueprint (plan) of the instance of a class (object). It can be defined as a logical template that share common properties and methods.
Object : The object is an instance of a class. It is an entity that has behavior and state.
Method : The behavior of an object is the method.
Instance variables : Every object has its own unique set of instance variables. The state of an object is generally created by the values that are assigned to these instance variables.
Sample Hello World Java Program:
// HelloWord.java file
import java.util.*;
public class HelloWord {
public static void main(String[] args)
{
System.out.println("Hello World!");
}
}
Example: Steps to compile and run a java program in a console
Compile
javac HelloWord.java
Run
java HelloWord
Output:
Hello World!