日期:2014-05-20  浏览次数:20929 次

初学java 编译时出现“需要标示符”是什么意思
源代码如下
STU_MSG.java//
class Student
{
  int studentId;
  int classId;
  String studentName=new String();;
  String StudentSex=new String();
  int studentAge;
  Student(int stuId,int claId,String stuName,String stuSex,int StuAge)
  {
  studentId=stuId;
  classId=claId;
  studentName=stuName;
  StudentSex=stuSex;
  studentAge=StuAge;
  }
  void getStudentId()
  {
  System.out.println("学号:"+studentId+'\n');
  }
  void getClass()
  {
  System.out.println("班级:"+classId+'\n');
  }
  void getStudentName()
  {
  System.out.println("姓名:"+studentName+'\n');
  }
  void getStudentSex()
  {
  System.out.println("性别:"+StudentSex+'\n');
  }
  void getStudentAge()
  {
  System.out.println("年龄:"+studentAge+'\n');
  }
  void setStudentAge(int NewAge)
  {
  studentAge=NewAge;
  System.out.println("新年龄:"+studentAge+'\n');
  }
 }
 public class STU_MSG
{
  public static void main(String[] args);
  Student P=new Student(2010011237,1,"赵旭","男",20);
  P.getStudentId();
  P.getClass();
  P.getStudentName();
  P.getStudentSex();
  P.getStudentAge();
  P.setStudentAge(18);
}
求指教  
   
   
   
 

------解决方案--------------------
STU_MSG中的main函数要用{}给括起来
getClass和系统的getClass起冲突了,换成别的名字