Getter/Setter from separate class file in Java
Posted
by Crystal
on Stack Overflow
See other posts from Stack Overflow
or by Crystal
Published on 2010-04-25T05:32:45Z
Indexed on
2010/04/25
5:43 UTC
Read the original article
Hit count: 209
I'm new to Java and for a HW assignment, we had to create a Person class that has a constructor, getter/setter for the attributes of firstName, lastName, phone. That is in a separate file from an old HW assignment (Person.java). Now we have to use that Person class in our new HW assignment (LoanApplication.java). So if one of the attributes is
private Person client
do I need to create getter/setters or a constructor again? Otherwise, how does each LoanApplicaiton instance know which Person attribute it is to go with?
How does the JVM know that it can use the Person.class even though my LoanApplicaiton.class does not extend Person.class? Thanks.
© Stack Overflow or respective owner