Java Theory
Class:
A class is a group of objects which have common properties. It is a template or blueprint from which objects are created. In short, a class is the specification or template of an object.
A real-world example is Circle. Let’s look at an example of a class and analyze its various parts in a diagram below. This example declares the class Circle, which has the member variables x, y, and radius of type Integer and the two member methods, area()and fillColor().
Diagram:
Class Example
Syntax |
---|
Class (name of the class) { (Here define member of class) } |
Example |
---|
public class Main { public static void main(String[] args) { System.out.println("Hello, World!"); } } |