我学过C++的 现在跳着学JAVA呢 可是编译通过不能运行
public class test1{
int a;
char b;
 public void max(int a,int b)
{
System.out.println(a>b? a:b);
}
   public void main(String[] args){
test1 t= new test1();
t.max(3,4);
}
}
运行就提示
Exception in thread “main” java.lang.NoSuchMethodError:main
很菜的问题

解决方案 »

  1.   

    我设置的classpath没错的 我验证过别人写的程序。
      

  2.   

    public static void main
      

  3.   

     class Test1{
        int a;
        char b;
     public void max(int a,int b)
        {
            System.out.println(a>b? a:b);
        }
     
       public static void main(String[] args){
        Test1 t= new Test1();
        t.max(3,4);
        }
     }
    可以运行
      

  4.   

    http://www.51cto.com/specbook/449/37490.htm
    Java中static、this、super、final用法
    我才找的 以前一直都是用  public static void main(String【】 arge)
    都没想过 static的用处... 大家看看会有帮助的