I remember someone telling me that there is the heap, the stack and something else.
methods are stored in ..something.. and variables somewhere - and even if they're not currently storing anything in the memory location - it's still "reserved"?
1. Does that mean it doesn't matter if I do int a = 12; and then a for loop or if I do (for(int a =12; etc?
Like, what about strings? The more data it holds it will grow bigger?
or vectors/lists.
2. Does it grow bigger? And should I do String x = null, or, String x = "" when it doesn't hold anything that I need to read anymore (but I still need that variable for input later)?
3.
What about if I use new Class() ?
Like, if I need input, is
Scanner scn = new Scanner(System.in) and then scn.nextLine()
and
String a = new Scanner(System.in).nextLine()
Does either of these take up more memory than the other?
4.
Of if I have variable declarations inside a method, does it matter if it's inside the method or outside? Memory-wise?