Java - Class Class Introduction

What Is a Class?

Classes are the basic units of programming in the object-oriented program.

Java Class

A class in Java may consist of five components:

  • Fields
  • Methods
  • Constructors
  • Static initializers
  • Instance initializers

Note

Fields and methods are members of the class.

Classes and interfaces can also be members of a class.

Constructors creates objects of a class.

You must have at least one constructor for a class.

Initializers are used to initialize fields of a class.

The initializers of static or instance types are optional.

Related Topics