1无法找到符号:编译java代码时

时间:2015-02-02 10:53:21

标签: java

我写过这个程序。当我编译它时,它会给出错误Symbol not find Plz帮助我。

// File Test.java

import javax.swing.*;
import javax.io.*;

public class Test {

public static void main(String args[]){

  Student s1 = newStudent("ali",15);
  student S2 = newStudent();

  s1.print();
  s2.print();

  s2.setName("usman");
  s2.setRollNo(20);

  System.out.println("Student name:"+ s2.getName());
  System.out.println("rollNo:" + s2.getRollNo());

  System.out.println("calling copy constructor");
  Student s3 = newStudent(s2);

   s2.print();
   s3.print();

   s3.setRollNo(-10);

   s3.print();
  }
}

1 个答案:

答案 0 :(得分:2)

达累斯萨拉姆,

您需要将newStudent()替换为new student(),因此您的代码如下所示:

在:

Student s1 = newStudent("ali",15);
Student S2 = newStudent();

后:

Student s1 = new Student("ali",15);
Student S2 = new Student();
祝你好运。