A Java program can be thought of as a collection of a series of objects that work together by invoking each other's methods. The following is a brief introduction to the concepts of classes, objects, methods, and instance variables.
Object: An object is an instance of a class that has state and behavior. For example, a dog is an object whose state is: color, name, variety, behavior: wagging the tail, barking, eating, etc.
Class: A class is a template that describes the behavior and state of a class of objects.
Method: The method is the behavior, a class can have many methods. Logical operations, data modifications, and all actions are done in a method.
Instance variables: Each object has a unique instance variable, and the state of the object is determined by the value of these instance variables.
The first Java program
Here's a simple Java program that will print the string HelloWorld
Instance:
public class HelloWorld {
/* First Java program
* It will print the string Hello World
*/
public static void Main (String []args) {
System.out.println ("Hello World"); Print Hello World
}
}
Java Basic Syntax