java casting a list
- by dcp
Let's say I had:
protected void performLogic(List<Object> docs) {
...
}
In the code where I'm going to be calling this method, I have a List<String> list. I want to call performLogic, passing this list. But it won't work because the lists are 2 different types:
public void execute() {
List<String> docs = new ArrayList<String>();
performLogin(docs); // won't work
}
I tried casting to List<Object> also, but that won't work either.
So is the only way to do this is to make a new ArrayList of Object and just add the values and then pass it? Just seems cumbersome. I wondered if there was a better way to do it.
Thanks.