My first class.(named Person.java)
public class Person {
// Instance variables
private String name;
private String address;
// Constructor
public Person(String name, String address) {
this.name = name;
this.address = address;
}
// Getters
public String getName() {
return this.name;
}
public String getAddress() {
return this.address;
}
public String toString() {
return this.name + "(" + this.address + ")";
}
}
My second class.(named Student.java)
public class Student extends Person {
// Instance variables
private String subject;
// Constructor
public Student(String name, String adress, String subject){
super(name, adress);
this.subject = subject
}
// getters
public String getSubject(){
return this.subject ;
}
}
My class that uses those two classes.(run method is like the main)
import acm.program.*;
public class Test extends Program{
public void run() {
Student obj1 = new Student("Kwnstantinos", "Liakataiwn", "math");
}
}
I am writing the following in the cmd to compile it but I got cannot find symbol error in compilation.
javac -cp acm.jar Person.java Student.java Test.java
I tried to make an Person's class object and it worked but when I am trying to create a Student's class object I get this error.Why is this happening.
C:\Users\Kwnstantinos\Desktop\JAVA>javac -cp acm.jar Person.java Student.java Test.java
Test.java:6: error: cannot find symbol
Student obj1 = new Student("Kwnstantinos", "Liakataiwn", "math");
^
symbol: class Student
location: class Test
Test.java:6: error: cannot find symbol
Student obj1 = new Student("Kwnstantinos", "Liakataiwn", "math");
^
symbol: class Student
location: class Test
2 errors