Error: Type Mismatch: Cannot Convert From Arraylist To Arraylist
Hi I have one xml file successfully parsed my before. now i am change simple modification in my xml file after i am getting lot of error. how to solve this error i don't know i pos
Solution 1:
Your method getSLTag is declared to return an ArrayList<String> but the variable sltag in the xmlTag class is actually an ArrayList<SubChild> hence the type mismatch.
So to answer your additional comment about wanting to get path string from sltag, you will need to iterate over the collection of SubChilds and add each path to a new List of Strings, e.g.
publicArrayList<String> getSLTag(String hltag) {
List<String> slTags = newArrayList<String>();
for(int i = 0; i < xmlTagInfo.size(); i++) {
if( xmlTagInfo.get(i).hltag == hltag ) {
for (SubChild child : xmlTagInfo.get(i).sltag) {
// Your SubChild class actually declares path and name to be an ArrayList of Strings, but surely they should just be Strings?
slTags.add(child.getPath());
}
}
}
return slTags;
}
Post a Comment for "Error: Type Mismatch: Cannot Convert From Arraylist To Arraylist"