I’m trying to pass a class instance into a constructor of another class and vise versa. I would like to do this:
static Map map = new Map(hero);
static Hero hero = new Hero(map);
I’m running this code inside my Game class. How do I go about correctly implementing the above code? Is there a better way to go about it?
EDIT:
I think what I really want is lazy loading, like if map is null then make it; otherwise, don’t make it. How do I do this in Java?
Basically, I made it so that I’m never creating a World class inside of any other class and that my World class would instantiate other classes if it needs them.
Thanks for your help everyone.