I have an arraylist
private ArrayList<Object> myList = new Arraylist<>()
This arraylist contains String values and SongInfoModel(object) values.
How to retrieve these two into their respective arraylists?
private ArrayList<SongInfoModel> songList = new Arraylist<>()
private ArrayList<String> path= new Arraylist<>()
I'm using below given code, but it is giving me error in the "add" statement
for(Object ob: myList){
if(ob instanceof SongInfoModel) {
songList.add(ob); //error
}else if(ob instanceof String){
path.add(ob); //error
}
}
I know this is a noobish question, but please help me!
SongListonce andsongListthe second time. Similarly,PathNameandpathseemingly interchangeably