Java Basic Tutorial
Java Advance Tutorial
Java is an object-oriented programming language where the building blocks are classes, fields, constructors, methods, and objects. Let’s understand each of them in detail.
class ClassName {
// Fields
// Constructors
// Methods
}
class ClassName {
DataType fieldName; // Field declaration
}
A constructor is a special method used to initialize an object. It is automatically called when an object is created.
class ClassName {
ClassName() {
// Constructor logic
}
}
class ClassName {
ReturnType methodName(Parameters) {
// Method logic
}
}
ClassName objectName = new ClassName();
Try it yourself
You can create multiple objects of one class:
Try it yourself