關于set和get方法和老師寫的代碼一樣,為什么就是運行不了,求大神指明錯誤?
第九行錯誤顯示:the method setCore(int) is undefined for the type Car.
第十行錯誤顯示:the method getCore(int) is undefined for the type Car.
第九行錯誤顯示:the method setCore(int) is undefined for the type Car.
第十行錯誤顯示:the method getCore(int) is undefined for the type Car.
2019-02-19
舉報
2019-02-19
public class Car{
? ? ? ?? private int core;
? ? ? ?? public void setCore(int core){
? ? ? ? ? this.core = core;
}
? ? ? ?? public int getCore(){
? ? ? ?? return this.core
}
? ? ? ?? Car hello = new Car();
? ? ? ?? System.out.print(hello.core(6));
2019-02-28
不是,你自己的類名是Inicar,創建類的對象也是 ?IniCar? hello = new? IniCar();
2019-02-19
代碼我看著沒問題,你應該是沒保存,保存一下再運行