Learning Java - Inheretance [SOLVED]

Hello I am trying to teach myself java and have set up a small test scenario.

I have three classes app(MAIN), delegate and person. with delegate extending person.
"public class Delegate extends Person"

when app calls delegate to print information
"store.show();"
I can't print info from person.

public void show()
{
System.out.println("\nDelegateRef:\t " + delegateRef);
System.out.println("Name:\t\t " + firstName + " " + secondName);

(First name and second name are stored in person but inherited)
please help

FIXED!

getFName()

public String getFName()
{
return firstName;
}

Hiya, you should check out the different access modifiers which Java offers you.
https://docs.oracle.com/javase/tutorial/java/javaOO/accesscontrol.html

Good luck on your programming journey :)

1 Like