Path: csiph.com!x330-a1.tempe.blueboxinc.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!nx02.iad01.newshosting.com!newshosting.com!69.16.185.11.MISMATCH!npeer01.iad.highwinds-media.com!news.highwinds-media.com!feed-me.highwinds-media.com!post01.iad.highwinds-media.com!newsfe15.iad.POSTED!00000000!not-for-mail From: Owen Jacobson Newsgroups: comp.lang.java.programmer Message-ID: <2011040801014026003-angrybaldguy@gmailcom> References: <25875c94-9af2-4d28-976d-2050a738ae2e@n10g2000yqf.googlegroups.com> <4sOdneh7k40lDgPQnZ2dnUVZ_vSdnZ2d@earthlink.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1; format=flowed Content-Transfer-Encoding: 8bit Subject: Re: Why only public methods on interfaces? User-Agent: Unison/2.1.4 Lines: 27 X-Complaints-To: abuse@UsenetServer.com NNTP-Posting-Date: Fri, 08 Apr 2011 05:01:40 UTC Date: Fri, 8 Apr 2011 01:01:40 -0400 Xref: x330-a1.tempe.blueboxinc.net comp.lang.java.programmer:2980 On 2011-04-08 00:49:02 -0400, Patricia Shanahan said: > On 4/7/2011 5:09 PM, kramer31 wrote: >> Could someone please explain to me the rational behind only allowing >> public methods on interfaces? In my mind, protection and interfaces >> are two independent if perhaps somewhat related concepts. > > I think the original Java design underestimated the extreme usefulness > of Java interfaces. At the time one of their uses, representing the > public face of a package, was assumed to be the only possible use. > > I've wanted to use intra-package interfaces, containing only default > access methods. There is an unpleasant choice between making something > that should be an interface into an abstract class or having public > methods that are supposed to only be used within one package. As Stefan pointed out, interfaces themselves don't have to be public. This is legal: package com.example; interface SomeInternalAbstraction { public void flog(Horse horse); } -o