SCJP 1.5, SCJD 1.6
javac Testarraylist.java -Xlint
Testarraylist.java:8: incompatible types
found : ArrayList
required: java.util.List
List test = new ArrayList();
^
SCJP 6 | SCWCD 5 | Javaranch SCJP FAQ | SCWCD Links
Henry Wong wrote:
javac Testarraylist.java -Xlint
Testarraylist.java:8: incompatible types
found : ArrayList
required: java.util.List
List test = new ArrayList();
^
Do you happen to have you own ArrayList class defined somewhere?
Henry
piya rai wrote:
but why am i getting the error on line seveteen , also these bunch of warnings??
C:\JAVA PROGRAMS>javac Testarraylist.java -Xlint
Testarraylist.java:10: warning: [unchecked] unchecked call to add(E) as a member
of the raw type java.util.List
test.add("string");
^
Testarraylist.java:11: warning: [unchecked] unchecked call to add(E) as a member
of the raw type java.util.List
test.add(s);
^
Testarraylist.java:12: warning: [unchecked] unchecked call to add(E) as a member
of the raw type java.util.List
test.add(s+s);
SCJP 6 | SCWCD 5 | Javaranch SCJP FAQ | SCWCD Links
Ankit Garg wrote:
piya rai wrote:
but why am i getting the error on line seveteen , also these bunch of warnings??
C:\JAVA PROGRAMS>javac Testarraylist.java -Xlint
Testarraylist.java:10: warning: [unchecked] unchecked call to add(E) as a member
of the raw type java.util.List
test.add("string");
^
Testarraylist.java:11: warning: [unchecked] unchecked call to add(E) as a member
of the raw type java.util.List
test.add(s);
^
Testarraylist.java:12: warning: [unchecked] unchecked call to add(E) as a member
of the raw type java.util.List
test.add(s+s);
I think you are talking about error in this statement
System.out.println(test.size("hihi"));
You will get error in this statement. What are you trying to do here. There is no method named size in List interface which takes a string.
As far as the warning goes, your code uses legacy non-generic code with collection classes that's why you are getting the warnings...
piya rai wrote:ps: ankit you were right , i checked the method in the API doc.Just to ask you, should i be really thorough with the api doc before exam, to do well?? cause there are so many method , there arguments , its not very easy to remember everything in there.Any special tips to score well, from your side?
SCJP 6 | SCWCD 5 | Javaranch SCJP FAQ | SCWCD Links