Java Basic Syntax
Categories: Java 8(JDK1.8)
A Java program is a collection of objects, and these objects communicate through method calls to each other to work together. Here is a brief discussion on the Classes and Objects, Method, Instance variables, syntax, and semantics of Java.
Basic terminologies in Java
1. Class: The class is a blueprint (plan) of the instance of a class (object). It can be defined as a template which describes the data and behaviour associated with its instance.
Example: Blueprint of the house is class.
2. Object: The object is an instance of a class. It is an entity which has behaviour and state.
Example: A car is an object whose states are: brand, colour, number-plate.
Behaviour: Running on the road.
3. Method: The behaviour of an object is the method.
Example: The fuel indicator indicates the amount of fuel left in the car.
4. 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.
The Basic Syntax:
1. Comments in Java
There are three types of comments in Java.
i. Single line Comment
// System.out.println("GFG!");
ii. Multi-line Comment
/*
System.out.println("GFG!");
System.out.println("Alice!");
*/
iii. Documentation Comment. Also called a doc comment.
/** documentation */