I'm writing a code that is using ArrayList
this is the part that is giving me the error. There are several instancses of this error but I figure that if I can get once fixed I can fix them all.

ArrayList <Student> studentList = new ArrayList <Student>();
		ArrayList <Course> courseList = new ArrayList <Course>();

		if(studentExists(s.getStudentID()) != -1)

it gives me this error

E:\Registration.java:32: cannot find symbol
symbol : method getStudentID()
location: class java.lang.Object
if(studentList.get(i).getStudentID().equals(str))

Recommended Answers

All 3 Replies

Check the spelling of the method.

You don't show what code is getting that "s" object s.getStudentID() but "s" is not getting cast to Student. It's still just Object, as indicated by the error message.

Of course. Never payed attention to that, as casting should no longer be needed when using Generics, but you're right, we have no idea how he defined "s". (And me, idiot, completely overlooked "Object" in the error message.)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.