0
Имя конструктора и класса.
почему сначало пишет, что имя конструктора должно быть таким же как и имя класса. а в третьем задании конструктор не называется как имя класса ?
6 Answers
+ 2
Can you copy that third question, we to see and answer correctly?
+ 1
Then tell us path of that question. I mean module: classes and objects--> constructor and so on
+ 1
There is not constructor yet, it is just an object
+ 1
Vehicle v = new Vehicle("Blue") is object, not a constructor. Constructor would be MyClass() {
//some code
}
0
sorry. it is very difficult to copy the text and code. and then put it here.
0
https://www.sololearn.com/learn/Java/2157/
- The name of the constructor must be the same as the class name.
public class Vehicle {
private String color;
Vehicle() {
color = "Red";
}
}
but page three
public class MyClass {
public static void main(String[ ] args) {
Vehicle v = new Vehicle("Blue");
}
}
The constructor name and class name are different