java - Are static variables inherited -


i have read @ 1000's of locations static variables not inherited. how code works fine?

parent.java

public class parent {         static string str = "parent";     } 

child.java

public class child extends parent {         public static void main(string [] args)         {             system.out.println(child.str);         }     } 

this code prints "parent".

also read @ few locations concept of data hiding.

parent.java

public class parent {     static string str = "parent"; } 

child.java

public class child extends parent {     static string str = "child";      public static void main(string [] args)     {         system.out.println(child.str);     } } 

now output "child".

so mean static variables inherited follow concept of data-hiding?

please have documentation of oracle: http://docs.oracle.com/javase/specs/jls/se8/html/jls-8.html#d5e12110

static variables inherited long not hidden static variable same identifier.


Comments

Popular posts from this blog

Command prompt result in label. Python 2.7 -

javascript - How do I use URL parameters to change link href on page? -

amazon web services - AWS Route53 Trying To Get Site To Resolve To www -