I tried finding it, but I don't have suitable knowledge on terminology and can't really ask proper question on Google.
First: I am making a structure similar to Tree, where one Object has Map of children, same for child and next...
public class Attribute
{
private String key;
private int value;
private HashMap<String, Attribute> modifiers;
public Attribute(String key, int value)
{
this.key = key;
this.value = value;
}
}
The MODIFIERS is only initialized when you actually put something in it (using local void method ofc). How much memory (if it is) is used by HashMap
on JUST declaration (like in code above)?
Second: Player is ofc. player object that stores all data for player.
public class Something
{
private Player player;
public Something() {}
public Something(Player player)
{
this.player = player;
}
}
1: Similar question, if I'd call Something(), is not-initialized PLAYER object using some memory, how much? Somewhere I read that when you declare 'something', memory is assigned based on the type of this 'something'. But how does it work with objects?
2: If I'd call Something(Player player), and since I am making a reference to object that already exist, how much memory this reference uses? (this.PLAYER = player) I am guessing that referencing like this is something like pointer, but how much memory it uses, is it constant for all objects in Java?