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

Retrieving ETA (estimated time of arrival) with Google Distance Matrix API and public transit as transport mode -

javascript - Confirm a form & display message if form is valid with JQuery -

ionic framework - Meteor - Error: Failed to execute 'insertBefore' on 'Node' -