155 pts.
 Recompile in java
When I compile my java source code it shows me a note: Recompile with -xlint:unchecked for details. Can any one explain me why it is showing such a note?

Software/Hardware used:
ASKED: December 5, 2012  7:14 AM

Answer Wiki:
Last Wiki Answer Submitted:  Be the first to answer this question.
All Answer Wiki Contributors:  Be the first to answer this question. v1i2b3h4a5   155 pts.
To see all answers submitted to the Answer Wiki: View Answer History.


Discuss This Question:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _


 

Can any one explain me why it is showing such a note?
 
No, not unless we had the code you are compiling and your compile environment.
 
In order to tell, we would have to run your compile and add the -xlint:unchecked option when compiling. Then we could look at what the compiler messages were and tell you.
 
It would be a lot easier if you did it, though.
 
Tom

 107,995 pts.

 

This is my code and my compile environment is JDK7import java.util.*;

public class CIDemo{
public static void main(String[] args){

List ls = new ArrayList();
ls.add(“ABC”);
ls.add(“xyz”);
ls.add(“abc”);
System.out.println(“Elements of array list \n”);

Iterator itr = ls.iterator();
while(itr.hasNext()){
Object ele = itr.next();
System.out.println(ele);
}
}//End of main
}//End of Collection interface

 155 pts.

 

What happened when you recompiled with -Xlint:unchecked specified? (If you won’t try it, why should we?) — Tom

 107,995 pts.

 

Finaly got it by just adding String after List and here is the code:import java.util.*;
public class CIDemo{
public static void main(String[] args){

List<String> ls = new ArrayList<String>();
ls.add(“ABC”);
ls.add(“xyz”);
ls.add(“abc”);

System.out.println(“Elements of array list \n”);

Iterator itr = ls.iterator();
while(itr.hasNext()){
Object ele = itr.next();
System.out.println(ele);
}
}//End of main
}//End of Collection interface

 155 pts.