0

Does creating multiple objects for a single class is useful? Or just consumes space?

27th Jul 2018, 7:22 AM
Nathan
Nathan - avatar
2 odpowiedzi
0
Not that i meant....I'll give an example, Class Vehicle { Void vehicleSpeed(int s){ System.out.println(s); } } public class A{ public static void main(String [] args){ Vehicle obj1=new Vehicle (); Vehicle obj2=new Vehicle (); obj1.vehicleSpeed(100); obj2.vehicleSpeed(50); } } In the above program, I've used 2 objects for the same class vehicle ; i can simply use obj1 for passing100 and 50; but does creating multiple objects for same class will be efficient or just consumes space?? this is my question
27th Jul 2018, 8:12 AM
Nathan
Nathan - avatar
0
Haha
27th Jul 2018, 8:22 AM
Nathan
Nathan - avatar