I have a java app which has the following classes: Car and Phone. Each class has the method connectToBluetooth(), which prints a message regarding the class' connection to bluetooth.
In another class, I want to create an array of objects in which I add the instances of each one of the objects already created. Then, I want to access the connectToBluetooth method coresponding to each instance. I have created one instance for each class:
I want to create an array of these two instances and to access the connectToBluetooth method coresponding to each class. (The constructors ask for the owner and the device's color )
Car car = new Car("John", "red");
car.connectToBluetooth();
Phone phone = new Phone("Susan","black");
phone.connectToBluetooth();