In Java, an object is created from a class.
To create an object of MyClass , specify the class name, followed by the object name, and use the keyword new :
|
|
Creating Multiple Objects
You can create multiple objects of one class: |
|
Using Multiple Classes
You can also create an object of a class and access it in another class. This is often used for better organization of classes (one class has all the attributes and methods, while the other class holds the main() MyClass.java and OtherClass.java .
|
|