gpt4 book ai didi

java - 无法从类型二对非静态方法 fxn(int) 进行静态引用

转载 作者:搜寻专家 更新时间:2023-10-30 19:49:37 24 4
gpt4 key购买 nike

<分区>

Possible Duplicate:
What is the reason behind “non-static method cannot be referenced from a static context”?
Cannot make a static reference to the non-static method
cannot make a static reference to the non-static field

我无法理解我的代码有什么问题。

class Two {
public static void main(String[] args) {
int x = 0;

System.out.println("x = " + x);
x = fxn(x);
System.out.println("x = " + x);
}

int fxn(int y) {
y = 5;
return y;
}
}

线程“main”中的异常 java.lang.Error: Unresolved 编译问题:无法从类型二对非静态方法 fxn(int) 进行静态引用

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com