• Post Reply Bookmark Topic Watch Topic
  • New Topic

Why is the warning " Warnings from last compilation" generated?  RSS feed

 
Ranch Hand
Posts: 177
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Why do I get the warning "Warnings from Last compilation
Note:\\ \ \ \Responder.java unchecked or unsafe operations may occur
Recompile with -Xlint:unchecked for details." When compiling the above responder.java class even when
ArrayList object is created with the <String> parameter specified

 
author and iconoclast
Sheriff
Posts: 24217
38
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The message tells you to recompile with the flag -Xlint:unchecked; did you do that?

Although honestly, you'd still have to guess at what the problem is. Look at the declaration of responseList. It's only the declaration that determines the type of the variable; the compiler doesn't care what you assign to it. The variable itself needs the type parameter.
 
Varuna Seneviratna
Ranch Hand
Posts: 177
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When compiled with the flag Xlint-Unchecked, I get 9 warnings each generated for each of the 9 rasponseList.add(".......") statements.After declaring the ArrayList variable responceList with <String> parameter the warning message doesn't pop up.But specifying the type of the ArrayList variable at the time of declaration it restricts the use of the ArrayList variable according to the needs arising inside the class, Is it not?
 
Marshal
Posts: 56600
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Restricting your List to contain only Strings makes your program much more reliable. Look at the generics section of the Java™ Tutorials. The "introduction" may supply all the information you require at present.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!