Objects & Classes - Beginner question
Ive just started a programming course but i have entered a semester behind so im rushing to catch up. My question is why is this not printing the correct name, phone and id????
Class file
Code:
public class Student {
private String name;
private String phone;
private String studNo;
public Student(String name, String phone, String studNo){
this.name = name;
this.phone = phone;
this.studNo = studNo;
}
public String getName(){
return this.name;
}
public String getPhone(){
return this.phone;
}
public String getStudNo(){
return this.studNo;
}
}
Test file
Code:
public class StudentTest {
public static void main(String[] args){
Student s1, s2;
s1 = new Student("Jony", "042", "123");
s2 = new Student("Michael", "123465", "98765");
System.out.println(s1);
System.out.println(s2);
}
}
The out put is -Student@3ae48e1b
Student@732dacd1
also if i change the phone and studNo to int it gives me this error msg - "The constructor Student(String, String, String) is undefined"