Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

access specifiers

 
Kelvin Chenhao Lim
Ranch Hand
Posts: 513
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
By the way, Java programmers don't usually use the term "friendly" to refer to default visibility. You should use the term "package private" instead.
 
Joseph Sweet
Ranch Hand
Posts: 327
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Everyone!

Both files are in the same directory:






Eclipse says on class D, method foo():

Cannot reduce the visibility of the inherited method from A


But why??? In A, foo() is defined to be friendly. In D, it's still friendly. Where did I reduce the visibility???
 
Joseph Sweet
Ranch Hand
Posts: 327
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks!
Learned something new.
 
Kelvin Chenhao Lim
Ranch Hand
Posts: 513
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Interface methods are always public, even if you don't explicitly declare their visibility. Your D class must therefore declare foo() to be public.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic