🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.jbuilder.java.language
Article #175

Re: warning: [unchecked] unchecked conversion

#175
From: Paul Furbacher [TeamB]
Date: Tue, 04 Apr 2006 15:47
58 lines
2513 bytes
Raul Lorenzo wrote:
> Hello,
> 
> I have this piece of code:
> 
> ArrayList<Element> children = new ArrayList<Element>();
> children.addAll(current.getOwnedElement());
> 
> What do I need to add to second line to remove the warning?

What warning are you getting?

Oh, you violated rule #0 -- NEVER put valuable information
in the subject line!

What is the declared return type for "current.getOwnedElement()"?

Collection<Element>?

as in ...

public class GenericsTest {
   public GenericsTest() {
   }

   public static void main(String[] args) {
     GenericsTest test = new GenericsTest();
     Current current = new Current();
     ArrayList<Element> children = new ArrayList<Element>();
     children.addAll(current.getOwnedElement());
   }

   public static class Current {
     public Collection<Element> getOwnedElement() {
       return null;
     }
   }
}

Your choice of names seems odd: "ownedElement" doesn't
connote a collection required by "addAll".  "ownedElements"
would seem to be more appropriate.


-- 


Paul Furbacher (TeamB)

   Save time, search the archives:
        http://info.borland.com/newsgroups/ngsearch.html

   Is it in Joi Ellis's Faq-O-Matic?
        http://www.visi.com/~gyles19/fom-serve/cache/1.html

   Finally, please send responses to the newsgroup only.
   That means, do not send email directly to me.
   Thank you.
Technical Details
Message-ID: <44329514$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newsfeed00.sul.t-online.de!t-online.de!newsfeed.freenet.de!news.code-werk.net!open-news-network.org!news.soft-gems.net!reader.uucp.at!newsfeed.uucp.at!news.uucp.at!newsgroups.borland.com!not-for-mail
References: <4432880a$1@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Thread: f74b3,f529280ba60199cd
X-Google-Attributes: gidf74b3,public
X-Google-Language: ENGLISH,ASCII-7-bit
Date: Tue, 04 Apr 2006 11:47:33 -0400
From: "Paul Furbacher [TeamB]" <pfurbacher@mac.com>
Organization: Reverse Alchemy, Inc.
User-Agent: Thunderbird 1.5 (Macintosh/20051201)
MIME-Version: 1.0
Newsgroups: borland.public.jbuilder.java.language
Subject: Re: warning: [unchecked] unchecked conversion
References: <4432880a$1@newsgroups.borland.com>
In-Reply-To: <4432880a$1@newsgroups.borland.com>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
NNTP-Posting-Host: 69.142.194.228
Message-ID: <44329514$1@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1144165652 69.142.194.228 (4 Apr 2006 08:47:32 -0700)
Lines: 58
Path: arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newsfeed00.sul.t-online.de!t-online.de!newsfeed.freenet.de!news.code-werk.net!open-news-network.org!news.soft-gems.net!reader.uucp.at!newsfeed.uucp.at!news.uucp.at!newsgroups.borland.com!not-for-mail