I am trying to store students' data in main class, in the student class I did the following:
public class Student {
public static String name = "UNKNOWN";
Student(){
}
Student(String name) {
this.name = name;}
While in main I did the following:
public class Main {
public static void main (String[] args) {
//s1 is short for student1
Student s1 = new Student ("Chris");
Student s2 = new Student ("Layla");
Student s3 = new Student ("Mark");
This issue is, whenever I print a sx.name I'd always print the last one. So for the following code:
System.out.println(s1.name);
I'd get Mark, while it should be Chris.
