Path: csiph.com!x330-a1.tempe.blueboxinc.net!newsfeed.hal-mli.net!feeder3.hal-mli.net!newsfeed.hal-mli.net!feeder2.hal-mli.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, 30 Dec 2011 07:40:43 -0600 Date: Fri, 30 Dec 2011 05:40:38 -0800 From: Patricia Shanahan User-Agent: Mozilla/5.0 (Windows NT 5.1; rv:8.0) Gecko/20111105 Thunderbird/8.0 MIME-Version: 1.0 Newsgroups: comp.lang.java.programmer Subject: Re: Inner class and interface question (I posted some really long code) References: In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Message-ID: Lines: 23 X-Usenet-Provider: http://www.giganews.com NNTP-Posting-Host: 75.11.53.36 X-Trace: sv3-wfSZawBEtB6UwebOhU1a/cAlRMU5hVSCUZrxDG/qOcrDYKofAVDCkIin6umtOD9OSoLHjrCZe9h9j/i!mqtp+5M/S576uoJnii9QFrSnSI6peCcq9yoMjrQVNl4iQ9ZACnxI3+/Au7R59G3SD0UAiydCTCKD!1vzmxtGuu7ItxXMnS/V7CnsM7T2lzJ1r3ah3PA0QTE4= 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: 2349 Xref: x330-a1.tempe.blueboxinc.net comp.lang.java.programmer:11033 On 12/29/2011 11:02 PM, GGolf wrote: > On 12/28/2011 11:59 AM, Chad wrote: >> I'm want to put the getHead() method in the BagInterface. However, I >> can't do this because the compiler keeps saying it can't find 'class >> Node' in Location BagInterface. I guess this is because Node is an >> inner class of my LinkedList class. Ideas how to fix this? Ideally I >> want to preserve the inner class. > > Referencing an inner class in the way you have described doesn't seem > quite right. An interface shouldn't have any knowledge of its > implementors. You should probably extract the class so that it's no > longer an inner class. I disagree. It is very reasonable for a linked list implementation to have an inner class representing the nodes that will be linked together. I think it should remain, and indeed be made private. I do not think the interface should say anything at all about Node. There are other ways of implementing a bag that do not have any such class. The interface should deal entirely in terms of the generic type T, the payload data type. Patricia