eclipse中运行java程序


1
package ttt; 2 3 public class Testttt { 4 public static void main() { 5 Person p =new Person(); 6 p.name="lucy"; 7 p.age=12; 8 p.sex=1; 9 p.study(); 10 int a = p.addAge(2); 11 12 } 13 14 }
 1 package ttt;
 2 
 3 public class Person {
 4 
 5         public String name;
 6         public int age;
 7         public int sex;
 8 
 9         public void study() {
10             System.out.println("studing");
11         }
12         
13         public void showAge() {
14             System.out.println(age);
15         }
16         
17         public int addAge(int i) {
18             age+=i;
19             return age;
20         }
21 
22 }

在eclipse中运行java时没有java Application 通常是因为 定义的main方法没有写对 缺少了 ()中的内容。

改正:将Testttt的main方法的参数写完整即可。

	public static void main(String args[]) {

  

猜你喜欢

转载自www.cnblogs.com/zyxln/p/11732518.html