0

Имя конструктора и класса.

почему сначало пишет, что имя конструктора должно быть таким же как и имя класса. а в третьем задании конструктор не называется как имя класса ?

30th Dec 2017, 3:54 PM
Misket
Misket - avatar
7 odpowiedzi
+ 2
Can you copy that third question, we to see and answer correctly?
30th Dec 2017, 4:04 PM
Sad
Sad - avatar
+ 1
Then tell us path of that question. I mean module: classes and objects--> constructor and so on
30th Dec 2017, 4:15 PM
Sad
Sad - avatar
+ 1
There is not constructor yet, it is just an object
30th Dec 2017, 4:22 PM
Sad
Sad - avatar
+ 1
Vehicle v = new Vehicle("Blue") is object, not a constructor. Constructor would be MyClass() { //some code }
30th Dec 2017, 4:26 PM
Sad
Sad - avatar
0
sorry. it is very difficult to copy the text and code. and then put it here.
30th Dec 2017, 4:12 PM
Misket
Misket - avatar
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
30th Dec 2017, 4:20 PM
Misket
Misket - avatar