看下主函数有什么问题?
public class Student {
private static int studentNo;
private static String studentName;
private static String classNo;
private static float english;
private static float math;
private static float computer;
Student(){
studentNo=0;
studentName="";
classNo="";
english=0;
math=0;
computer=0;
}
Student(int no,String name,String classNo,
int english,int math,int computer ){
this.studentNo=no;
this.studentName=name;
this.classNo=classNo;
this.english=english;
this.math=math;
this.computer=computer;
}
public static int getNo(){
return studentNo;
}
public static String getName(){
return studentName;
}
public static String getclassNo(){
return classNo;
}
public static float getEnglish(){ //float 方法的返回值类型需要与一开始定义的值类型要一样
return english;
}
public static float getMath(){ //没有void 则必须要返回return一个值
return math;
}
public static float getComputer(){
return computer;
}public static float getAverage(){
return ((computer+math+english)/3);
}public static float getSum(){
return (english+math+computer);
}public static float getLow(){
float low=english;
if(low>math) low=math;
if(low>computer) low=computer;
return low;
}public static float getHigh(){
float high=english;
if(high<math) high=math; //记住少数几个数值输出的算法
if(high<computer)high=computer;
return high;
}}public class stu {
public static void main(String[] args)
{
Student bigti=new Student(82,"yishutian","xinxi",70,75,80);
System.out.println("StudentNO is"+Student.getNo());
//static声明的方法是可以用类名直接调用的~而没static就要new出对象来去调用
System.out.println("StudentName is"+Student.getName());
System.out.println("ClassNO is"+Student.getclassNo());
System.out.println("Low score is"+Student.getLow());
System.out.println("High score is"+Student.getHigh());
System.out.println("avarage is"+Student.getAverage());
}
}Error: Main method not found in class stu, please define the main method as:
public static void main(String[] args)
郁闷,求help。

解决方案 »

  1.   

    大哥啊 你那个Student 类不能写为public 啊 去掉就可以了
      

  2.   

    写在一个java文件里的话,Student类的public修饰符去掉
      

  3.   

    1.上面的代码你是两个类吗,如果是的那没有问题。
    2.如果在一个类写的,就请去掉public
      

  4.   

    两个类写在用一个java文件中,运行时只会执行public的类的main方法,你木有定义肯定错了
      

  5.   

    为什么我的写在两个类里,还得两个public都去掉
      

  6.   

    你是想用后面一个类来测试和输出,其实你可以写成两个类分开写。建议初学这不要两个类写在一起,因为这样就要熟悉内部类的知识。你得写法就相当于内部类要访问外部类的属性,而且你得mian方法还写在了内部类里了。
      

  7.   

         把public class stu {删掉,
         把mian方法写在Student类就可以了。
      

  8.   

    你两个类是在一个文件里还是在两个文件里啊,两个的话stu类名要与你的文件名一样的才能找到main,也就是stu.java
    要是在一个文件里,stu类要public,student类不能public,一个文件里只能一个public类