Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!news.dougwise.org!nntpfeed.proxad.net!proxad.net!feeder1-1.proxad.net!198.186.194.247.MISMATCH!news-out.readnews.com!transit3.readnews.com!nx02.iad01.newshosting.com!newshosting.com!216.196.98.144.MISMATCH!border3.nntp.dca.giganews.com!Xl.tags.giganews.com!border1.nntp.dca.giganews.com!nntp.giganews.com!local2.nntp.dca.giganews.com!nntp.earthlink.com!news.earthlink.com.POSTED!not-for-mail NNTP-Posting-Date: Fri, 08 Apr 2011 00:37:49 -0500 Date: Thu, 07 Apr 2011 22:37:57 -0700 From: Patricia Shanahan User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2.15) Gecko/20110303 Thunderbird/3.1.9 MIME-Version: 1.0 Newsgroups: comp.lang.java.programmer Subject: Re: Why only public methods on interfaces? References: <25875c94-9af2-4d28-976d-2050a738ae2e@n10g2000yqf.googlegroups.com> <4sOdneh7k40lDgPQnZ2dnUVZ_vSdnZ2d@earthlink.com> <2011040801014026003-angrybaldguy@gmailcom> In-Reply-To: <2011040801014026003-angrybaldguy@gmailcom> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Message-ID: <5YSdnThYKPSwAgPQnZ2dnUVZ_gydnZ2d@earthlink.com> Lines: 34 X-Usenet-Provider: http://www.giganews.com NNTP-Posting-Host: 75.8.126.96 X-Trace: sv3-ZKYz15LjSyXnMV7q858Gpo24k6FOw/J5jOekeAmwCROgJJL8SGCc8FQnKlvsnybCtcamp87dYjebsua!l0OwpfswGIAFXxQ8KBMU6LPdCx3MC3h01KlS0m8+7bSbwuTe19MVlXO2WGk7NR1ImK+n1Z1wXEg8!6SxOKTk92Fp5yWe5m+RM+F1JzE7Eyl4MU2oFWJucmQk= X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your complaint properly X-Postfilter: 1.3.40 X-Original-Bytes: 2544 Xref: x330-a1.tempe.blueboxinc.net comp.lang.java.programmer:2982 On 4/7/2011 10:01 PM, Owen Jacobson wrote: > 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 > Yes, but then the implementing methods do have to be public, which is undesirable if they should not be used outside the package. Patricia