Link to home
Create AccountLog in
Avatar of Brandon_Campbell
Brandon_CampbellFlag 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.
Avatar of ksivananth
Flag of United States of America image

you need to get the reference of that class instance and then access the hashmap through that instance.
Avatar of Sathish David  Kumar N
Can you paste ur code ?
Avatar of Sharon Seth
Sharon Seth
Flag of India image

Link to home
Create an account to see this answer
Signing up is free. No credit card required.
Create Account
Avatar of Brandon_Campbell


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,