I am trying to print the contents of a list, but I am getting the wrong values.
(com.school.student.StudentModel@949774e) instead of the query result
Below is the bean
public class StudentModel {
    int studentId;
    String studentName; 
    public int getStudentId() {
        return studentId;
    }
    public void setStudentId(int restaurantId) {
        this.studentId = resturantId;
    }
    public String getStudentName() {
        return studentName;
    }
    public void setStudentName(String studentName) {
        this.studentName = studentName;
    }
}
Query method:
public static List<StudentModel> StudentDetails() {
    Connection conn = connection.dbConnection();
    List<StudentModel> students = new ArrayList<StudentModel>();
    try {
        String checkCst = "select * from student";
        PreparedStatement stmt = conn.prepareStatement(checkCst);
        ResultSet rCST = stmt.executeQuery();
        while (rCST.next()) {
            StudentModel  rM = new StudentModel ();
            rM.setStudentId(rCST.getInt(1));
            rM.setStudentName(rCST.getString(2));
            students.add(rM);
        }
    } catch (Exception ex) {
        ex.printStackTrace();
    }
    return students;
}
This is how I tried to call the method:
StudentModel rM = new StudentModel();
List<StudentModel> student = ListStudentDetails.StudentDetails();
for (int i = 0; i < student.size(); i++) {
    System.out.println(" " + student.get(i));
    System.out.println(" " + student.get(i));
}
The query works fine, so I am assuming the issue occurs in the for loop when I call the StudentDetails method.
Thank you very much.
 
    