I am having trouble getting value from getter. I am trying to access the getter method from another class but it returns null.
In my Registration Class I have a constructor and getters.
In my Client Class I have set the values using Scanner.
I would like to create Report Class and access getters in order to print it out:
public RegistrationDetails(String name){
this.name = name;
}
public String getName() {
return name;
}
In my Client Class I used Scanner to set the name:
System.out.println("Enter Name: ");
name = in.nextLine();
RegistrationDetails registrationDetails = new RegistrationDetails(name);
In my Report Class when i do somthing like this:
RegistrationDetails registrationDetails = new RegistrationDetails();
registrationDetails.getName(); -- it returns NULL
Any suggestions how to fix it.
In my main class I have first called a method to set details and then to get it..