This the ERROR in Java code during compilation .What is this??
Note: ABC1.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
Now when i use :
javac ABC1.java -Xlint
ABC1.java:26: warning: [unchecked] unchecked call to add(E) as a member of
the raw type java.util.ArrayList
list1.add(p);
^
1 warning
Note: Recompile with -Xlint:unchecked for details.
Now when i use :
javac ABC1.java -Xlint
ABC1.java:26: warning: [unchecked] unchecked call to add(E) as a member of
the raw type java.util.ArrayList
list1.add(p);
^
1 warning
Replies
-
komputergeekI guess you haven't used try-catch block to catch exception in your program.Please post your program.
-
ms_csPost your full code here...It will be easy to debug..
-
shalini_goel14
This kind of warning you get when you use jdk1.5 to compile but not in actually using "Generics" feature of jdk1.5 properly or when you mix generic collections with non-generic collections and try to "add"(note not on retreive) something to the list that is not type-safe.sahilgandhi87Note: ABC1.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
Now when i use :
javac ABC1.java -Xlint
ABC1.java:26: warning: [unchecked] unchecked call to add(E) as a member of
the raw type java.util.ArrayList
list1.add(p);
^
1 warning
See the sample program for this:
package myjava; import java.util.*; /** * * @author shalinig */ public class TestBadLegacy { public static void main(String args[]){ List
So make insert method something like this:myList = new ArrayList (); myList.add(4); myList.add(6); Inserter in =new Inserter(); in.insert(myList); } } class Inserter{ void insert(List list){ //you need to use generics here also list.add(new String("42")); } }
void insert(Listlist) rather than void insert(List list)
Hope this may be of any help ๐
Thanks -
shalini_goel14Hey Sahil , Is your problem solved? Please devote some time to share the whole problem with solution here? ๐
Thanks
You are reading an archived discussion.
Related Posts
๐๐๐
can i use printer in my c programme for printing my bill in project..
i have used graphics...
thaqnk you
how to hack wifi connection "wep" secured...
๐๐
I am fresher in electronocs and comenication i want to prepair exam of b s n l so tell me a tips to clear the xam
Name: .::MAX::.
*Engineering Trade: Computer
Location: NANDED, MAHARASHTRA ๐
*Occupation: Student
*Hobbies & Interests : Posting!! :sshhh: ,Music :music:
*Aim in life: Be an Engineer!
*I joined CrazyEngineers because: I...
I'm headed to WESTEC 2009 next week and was wondering if any other CE's will be there.