Why contains() method takes Object, even if I have parameterized my ArrayList with String. Only String can be added and we need not to cast what get(...) method returns, but why contains() ,indexOf(),remove() ask for Object.
indexOf() also requires Object remove() also requires Object (another remove() asks for index though)
You are right. We will never be able to add anything other than string in to this list. But the same is not ture for the contains method.It can check for any thing other than the string.As you see the following prints false.
I know that you are going to ask me the question
"If it not taking in any thing other than string, why is it checking for some thing else?"