Consider the following block of code:
class CheckStore {
private String displayText;
private boolean state;
private String meaningfulText;
private URL url;
public CheckStore(String text, boolean state) {
this.displayText = text;
this.state = state;
}
:
:
}
When I initialize two variables (displayText
and state
) in the constructor, do the other two variables (meaningfulText
and url
) require space in the memory to store null
value?
Q1. If they do require space, how much memory does a null
value take in the memory?
(ex. int
takes 4 bytes).
Q2. How much space does a string take in memory? How much memory space does a string take? Does it depend on the length of the string?
Question&Answers:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…