GeeCON Prague 2014*
The moose likes Beginning Java and the fly likes access specifiers Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » Beginning Java
Bookmark "access specifiers" Watch "access specifiers" New topic
Author

access specifiers

Kelvin Chenhao Lim
Ranch Hand

Joined: Oct 20, 2007
Posts: 513
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.


SCJP 5.0
Joseph Sweet
Ranch Hand

Joined: Jan 29, 2005
Posts: 327
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???


We must know, we will know. -- David Hilbert
Joseph Sweet
Ranch Hand

Joined: Jan 29, 2005
Posts: 327
Thanks!
Learned something new.
Kelvin Chenhao Lim
Ranch Hand

Joined: Oct 20, 2007
Posts: 513
Interface methods are always public, even if you don't explicitly declare their visibility. Your D class must therefore declare foo() to be public.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: access specifiers