class Car {
public String name;
public String color;
Car(String name, String color) {
this.name = name;
this.color = color;
}
@Override
public String toString() {
return "the name is " + name + ", the color is " + color + ".";
}
}
public class Operator{
public static void main(String[] args) {
Car myCar = new Car("dang", "blue");
System.out.println(myCar.toString());
}
}
>>결과:
the name is dang, the color is blue.