关于Java小程序的一个错误 javastatic 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 没有构建对象,不可以调用非静态方法。可以改为:public class Test { public static void main(String[] args) { int a = 1; int b = 0; System.out.println(sum(a, b)); } public static int sum(int a, int b) { return (a + b); } }或:public class Test { public static void main(String[] args) { int a = 1; int b = 0; Test t = new Test(); System.out.println(t.sum(a, b)); } int sum(int a, int b) { return (a + b); } } java新手 这里为什么有错? 静态页面如何调用静态页面?有几种方法? java问题 输入输出 是用实例池还是静态方法? 新手求助!!!关于在java中如何实现树型显示文件路径的问题!!! 寻找jive研究者群 留下联系方式 简单问题,快来拿分 有更好的算法吗? 关于接口的问题.... 在构造器内唯一能够安全调用的那些方法是基类中的final或者private方法,这些方法不能被覆盖,因此也就不会出现令人惊讶的问题。 请大家看一看
可以改为:
public class Test {
public static void main(String[] args) {
int a = 1;
int b = 0;
System.out.println(sum(a, b));
}
public static int sum(int a, int b) {
return (a + b);
}
}
或:
public class Test {
public static void main(String[] args) {
int a = 1;
int b = 0;
Test t = new Test();
System.out.println(t.sum(a, b));
}
int sum(int a, int b) {
return (a + b);
}
}