• Post Reply Bookmark Topic Watch Topic
  • New Topic

How a subclass access to private of root class?  RSS feed

 
abalfazl hossein
Ranch Hand
Posts: 635
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How a subclass access to private of root class?

if it is possible, Is it good to use it?What are advantage and disadvantage of this manner?
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Private means private, as in you can't access it.
 
Jesper de Jong
Java Cowboy
Sheriff
Posts: 16060
88
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I guess that by "root class" you mean superclass.

A subclass cannot access private variables and methods from its superclass. When something is private, it means that it's only accessible from the class itself. See Controlling Access to Members of a Class in Sun's Java Tutorials.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!