If I create a static block and create an Object there, say of some other class, will the object be created on the heap or on the stack?
class Hello {
static {
Abc abcObject=new Abc();
}
// Other Code...
}
Objects are always on heap irrespective of static (or) non-static .
References will be on stack.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With