异常: 在类 testException 中找不到主方法, 请将主方法定义为: public static void main(String[] args
错误: 在类 testException 中找不到主方法, 请将主方法定义为: public static void main(String[] args
public class testException {
public static void main(String args[]){
int x=Integer.parseInt(args[0]);
int y=Integer.parseInt(args[1]);
System.out.println(x+"+"+y+"="+(x+y));
}
}
在dos命令行方式下可以运行,但是在eclipse 中就出现上述报错,到底是为什么!!
------解决方案--------------------
截图来更有发现问题
------解决方案--------------------
这个问题很简单啊!这种是操作主函数中的 String args[] 这个参数数组,这种只能在dos下运行,eclipse不支持这种操作,仅此而已。你想在eclipse里输入,你肯定要有输入类啊!JOptionPane或者Scanner这两种输入类都行,前者是弹出对话框输入,后者是控制台输入,看楼主个人的选择。等楼主了解到了GUI编程,就知道还有其他的输入办法了。
public class testException {
public static void main(String args[]){
int x=Integer.parseInt(args[0]);
int y=Integer.parseInt(args[1]);
System.out.println(x+"+"+y+"="+(x+y));
}
}
在dos命令行方式下可以运行,但是在eclipse 中就出现上述报错,到底是为什么!!
------解决方案--------------------
截图来更有发现问题
------解决方案--------------------
这个问题很简单啊!这种是操作主函数中的 String args[] 这个参数数组,这种只能在dos下运行,eclipse不支持这种操作,仅此而已。你想在eclipse里输入,你肯定要有输入类啊!JOptionPane或者Scanner这两种输入类都行,前者是弹出对话框输入,后者是控制台输入,看楼主个人的选择。等楼主了解到了GUI编程,就知道还有其他的输入办法了。