I am new to Java. I have a List of objects, that contains both strings and arrays.
List eg [["alfa","beta",["gamma","pi"], "foo"], ["alfa","beta",["gamma","pi"], "foo"]] where one object is ["alfa","beta",["gamma","pi"], "foo"]
I want to iterate like: "alfa" "beta" ["gamma", "pi"] "foo" ---- end----- –
How should I do that?
You could possibly try something like
for (Object object : listName) {
if(object.getClass() == String.class){
//do whatever string operations you want
} else{
if(object.getClass() == String[].class){
//do whatever string array operations you want
}
}
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.