Running Program with Objects
Objects are Anthropomorphic. We first need to make an instance by calling the constructor class by invoking the new keyword. After that the instance can be used to call all the class methods.
// Instantiation
LightBulb bulb1 = new LightBulb("white", 5);
// Using a class method
bulb1.turnOn();Runner Class
- Program in the main method
- Provides the entry point for the application
- This object can be the initiator for the interaction of different objects
public class Main{
public static void main(String[] args){
LightBulb bulb1 = new LightBulb("white", 5);
//runner program
}
}