Constructor
생성자
Time t = new Time();
t.hour = 12;
t.minute = 34;
t.second = 56;Time t = new Time(12,34,56);class Car {
String color;
String gearType;
int door;
Car() {}//default constructor
Car(String c, String g, ind d) {
//iv group
color = c;
gearType = g;
door = d;
}
}
//1.declare reference type variable
//2.create object using operator new
//3.initialize with calling constructor
Car c = new Car("white","auto",4);Last updated