Avatar of Brandon_Campbell
Brandon_Campbell
Flag for United States of America asked on

How to get values from a different class in a separate package

I have a program with several packages in the source folder. All packages have public classes with public getters and setters.

I have a class that needs to get a HashMap from another class in a different package that has already been instantiated. I went the route of importing the class but I cannot get access to the values. I did look at reflection but this did not pan out for me. Am I missing something obvious? At a loss for the moment.

Thank you.
JSPJava App ServersJava

Avatar of undefined
Last Comment
Brandon_Campbell

8/22/2022 - Mon
ksivananth

you need to get the reference of that class instance and then access the hashmap through that instance.
Sathish David Kumar N

Can you paste ur code ?
ASKER CERTIFIED SOLUTION
Sharon Seth

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
Brandon_Campbell

ASKER
While the variable was static the getter was only public. When I set the getter to public static HashMap then everything worked great.

Thank you,
Experts Exchange is like having an extremely knowledgeable team sitting and waiting for your call. Couldn't do my job half as well as I do without it!
James Murphy