这是我的代码:
public void start()
{
//If the gas tank and oil have more than nothing, and the transmission is in gear park, then the car can start
if((gasTank.getGasLevel() > 0) && (engine.getOilLevel() > 0) && (transmission.gearPark()))
{
engine.startEngine();
System.out.println("Engine is now on");
}
else
{
System.out.println("Please make sure your car is in proper gear, engine has oil and gas.");
}
}
Run Code Online (Sandbox Code Playgroud)
我一直在收到'void' type not allowed here错误.我不是想要返回任何东西所以我知道我不需要int,Boolean,double等.
我究竟做错了什么?
您的代码不在类中.
试试这个:
public class SomeClass {
// your method here
}
Run Code Online (Sandbox Code Playgroud)