Sb explain constructor please. | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Sb explain constructor please.

public class MyClass { public static void main(String[ ] args) { Vehicle v = new Vehicle("Blue"); } }

5th Aug 2017, 7:49 AM
Dariush Shiri
Dariush Shiri - avatar
1 Answer
+ 12
You create a new instance of the class Vehicle represented by object v, and then initialize the object with "Blue".
5th Aug 2017, 7:55 AM
Hatsy Rei
Hatsy Rei - avatar