File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Warning in adding to a Collection Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Warning in adding to a Collection" Watch "Warning in adding to a Collection" New topic

Warning in adding to a Collection

P Ventura
Ranch Hand

Joined: Jan 24, 2007
Posts: 42
Hi ranchers,
in what situation, adding to a Collection generates a warning, but compile fine?
I don't remember it and I can't found where I readed it?

Please help me I'm trying to fix errors ragarding generics concepts.

Objective: SCJP 1.5<br /><a href="" target="_blank" rel="nofollow">API</a><br /> <blockquote><font size="1" face="Verdana, Arial">code:</font><hr><pre><font size="2"><br />Double n1 = Double.NaN; Double n2 = Double.NaN;<br /> n1.equals(n2) // true even though Double.NaN != Double.NaN<br />-0.0 == +0.0; // true<br />Double n1 = -0.0;Double n2 = +0.0;<br />n1.equals(n2) // false even though -0.0 == +0.0<br /></font></pre><hr></blockquote>
Keith Lynn
Ranch Hand

Joined: Feb 07, 2005
Posts: 2398
If you try to add to a raw Collection, you will usually get a warning.
I agree. Here's the link:
subject: Warning in adding to a Collection
It's not a secret anymore!