它一直给我一个错误“此处不允许使用 Void 类型”。
public class BugTester {
public static void main(String[] args) {
Bug bugsy = new Bug(10);
bugsy.move(); //now the position is 11
bugsy.turn();
bugsy.move(); //now the position is 10
bugsy.move();
bugsy.move();
bugsy.move();
// Error message highlights this.
System.out.println("The bug position is at "+bugsy.move());
}
}
最佳答案
Bug的move()方法没有返回值。这是一个无效的方法。您不能将任何内容连接到字符串。
也许还有另一种 Bug 方法,您想打印 getPosition() 之类的值?
关于java - 错误 "Void type not allowed here."请帮助我,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4047718/