In Java, you create a class to represent a concept, for example, a User class. The User class has a constructor, some fields, and methods. And you use its constructor to instantiate a User object. And every object in Java is an instance of the associated class that provides code sharing among its instances. You can extend the User class to create, for example, a TeamMember class.
- The Object() constructor method
- The object literal method
- The constructor function method
- The Object.create() method
- The creator function method
- The ES6 class method
Let's look at each method one at a time.
The Object constructor method looks like this:
// Call the Object constructor ...