this - System.out.println(super) in java -


this question has answer here:

this in java works reference variable, super not, why? example: can system.out.println("this: " + this); can never system.out.println("super: " + super);

class base {     public base()     {         system.out.println("base constructor");     } }  class child extends base {     public child()     {         system.out.println("child constructor");         system.out.println("this: " + this);         //system.out.println("super: " + super);     } } 

the reason think of is, when use new keyword memory allocated in heap , reference id of memory saved in this. there no memory space allocation parent in heap there no reference id stored in super.

am wrong? or there missing with. can this reference variable & super not?

yes, that's right. there's no reference id can stored in super, that's why can't print it. super keyword used access parent data members/constructor.


Comments

Popular posts from this blog

ubuntu - PHP script to find files of certain extensions in a directory, returns populated array when run in browser, but empty array when run from terminal -

php - How can i create a user dashboard -

javascript - How to detect toggling of the fullscreen-toolbar in jQuery Mobile? -