看下主函数有什么问题?
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。
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。
2.如果在一个类写的,就请去掉public
把mian方法写在Student类就可以了。
要是在一个文件里,stu类要public,student类不能public,一个文件里只能一个public类