+ 2
Constructor questions
https://code.sololearn.com/cj38ilikf5xd/?ref=app 1 This constuctor is also a setter too? Vehicle() { this.setColor("Red"); } 2 How does it know that the color attribute have to change when i create a new object?(if i have more attribute in the Vehicle class) Vehicle v2 = new Vehicle("Green");
3 Answers
+ 1
thank you!
0
thank you!
But if i have more attributes:
Vehicle() {
color = "red";
}
Vehicle() {
color2 = "blue";
}
Vehicle(String color){
this.color = color;
Vehicle(String color2){
this.color2 = color2;
}
Vehicle v2 = new Vehicle("Green");
0
thank you!
But I have : Vehicle v2 = new Vehicle("Green");
Which will be alter color or color2?