Path: csiph.com!x330-a1.tempe.blueboxinc.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!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 10:59:47 -0500 Date: Fri, 08 Apr 2011 08:59:53 -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> <5YSdnThYKPSwAgPQnZ2dnUVZ_gydnZ2d@earthlink.com> In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Message-ID: <58-dnYYCMK1urQLQnZ2dnUVZ_gGdnZ2d@earthlink.com> Lines: 31 X-Usenet-Provider: http://www.giganews.com NNTP-Posting-Host: 75.8.126.96 X-Trace: sv3-V1lbLjfREr9zyXO7qUHqjZISCAayZxXo2ZB5Y5w1IiwzcQXszRe/Npkp3urmG1yKnnIHxeMPPiSA+6y!CQYU7yT6Vtty45PS4nnyBBQ/4/Bp/nPY7nhw759LUzQ+t6c3Pw2qttZBgc1xAuAj56s89jPlH8wt!gXcpt9BBGzeiTDcODVg/mDXKkV+qJQcYzmJSqjSVsJc= 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: 2804 Xref: x330-a1.tempe.blueboxinc.net comp.lang.java.programmer:2994 On 4/8/2011 7:17 AM, Peter Duniho wrote: > On 4/8/11 6:59 AM, Patricia Shanahan wrote: >> [...] >>>> Yes, but then the implementing methods do have to be public, which is >>>> undesirable if they should not be used outside the package. >>> >>> The implementing type doesn't have to be public either. >> >> How do you know that? Of course, implementing the interface does not >> require it to be public, but the class may also be part of the public >> face of the package. > > Since it's an implementation choice, you can just as easily choose to > implement the interface in a non-public class. Yes, it is often possible to work around the public-methods-only limitation, in several different ways, including a non-public inner class object that implements the interface on behalf of its surrounding class. Interfaces would have been even more useful than they are now if it were not necessary to work around the limitation. The really unfortunate decision is not the public methods only, but the decision to make non-specification of access mean public interface method declarations but package access in class method declarations. That cuts off any possibility of changing interfaces now to make them more flexible. Patricia