Classes in Java
Class
A class is a logical entity that serves as the basis for the definition of a new data type. Once defined, we can use this new data type to create objects of that type. As a result, we can define a class as a template for an object. Variables, methods, and constructors are all part of a Java class.
Syntax:
Modifier class className {
/*
Class Body
*/
}
In the above syntax:
- Modifiers: A class can have public or default access modifiers.
- class: The 'class' keyword is used to create a class in Java.
- ClassName: The name of the class should begin with a capital letter.
- Class Body: The class body is surrounded by curly braces.