有人可以请回答为什么这段代码给出错误吗?为什么void方法无法在system.out.println中调用
package hello;
public class Hello {
public void eat() {
System.out.println("eating");
}
private String run() {
return "dwedsdfsdfsdf fsdf rgdsfG";
}
public static void main(String[] args) {
//System.out.println("Hello bhopi");
//Hello hello = new Hello();
Hello mahir = new Hello();
//String y = mahir.eat();
System.out.println(mahir.run());
System.out.println(mahir.eat());
}
}
void方法返回什么? – LazerBanana
标记 - 关闭主题 - '为什么我的代码不起作用?是一个寻求调试支持的问题,不应该回答/询问。 – LazerBanana