输出乱码,请问应该如何改正?
public class Student {
public int Chn;
public int Mat;
public int Eng;
public int avr=(Chn+Mat+Eng)/3;
public int sum=Chn+Mat+Eng;
public String ToStudent(){
return ("the average score is"+avr+"the sum score is"+sum);
}
}
public class TestStudent
{
public static void main(String[] args)
{
Student KG=new Student();
Student KB=new Student();
KG.Chn=90;
KG.Mat=85;
KG.Eng=83;
KB.Chn=73;
KB.Mat=80;
KB.Eng=82;
System.out.println("KG:"+KG);
System.out.println("KB:"+KB);
}
}
结果如下:
KG:Student@c17164
KB:Student@1fb8ee3
本人意愿是输出KG和KB平均分和总分