ArrayList in Java, adding code to methods
Posted
by
yaz
on Stack Overflow
See other posts from Stack Overflow
or by yaz
Published on 2012-09-22T00:13:39Z
Indexed on
2012/09/22
3:37 UTC
Read the original article
Hit count: 342
Why am I getting a compile time error for the two method headers at the end of my code in my class ArrayListTest?
ArrayListTest: http://pastebin.com/dUHn9vPr
Student: http://pastebin.com/3Vz1Aytr
I have a compiler error at the two lines:
delete(CS242, s3)
replace(CS242, s, s4);
When I try to run the code it states:
Exception in thread "main" java.lang.Error: Unresolved compilation problems:
The method replace(ArrayList<Student>, Student, Student)in the type ArrayListTest is not applicable for the arguments (List<Student>, Student, Student)
The method delete(ArrayList<Student>, Student) in the type ArrayListTest is not applicable for the arguments (List<Student>, Student)
at ArrayListTest.main(ArrayListTest.java:54)
I fixed the compile time errors since I use Eclipse and Eclipse gives options of code you can use to fix the compile time error. I chose to "Change method to 'replace(ArrayList, Student, Student)' to 'replace(List, Student, Student)'
Although it fixed that compile time error, I don't understand why I was getting a compile time error to begin with and why that effectively fixed the error
I don't really know what missing code I need to write to correct these two methods below:
public static void replace(List<Student> cS242, Student oldItem,
Student newItem) {
public static void delete(List<Student> cS242, Student target){
© Stack Overflow or respective owner