F
Fencer
Say I have a List<SomeClass> and now I want to loop through the list but
I am only interested in the String representation of the SomeClass objects.
Do I have to do it like this:
for (SomeClass inst : aListOfSomeClass) {
String str = inst.toString();
// Do something with str
}
?
I don't really care about each instance objecct here, just the string
represenation of each instance, so is it possible to do something like
the following non-valid code (and here I imagine toString() being called
on each element):
for (String str : aListOfSomeClass.toString()) {
// Do something with str
}
Hope I made sense, thanks!
- Fencer
I am only interested in the String representation of the SomeClass objects.
Do I have to do it like this:
for (SomeClass inst : aListOfSomeClass) {
String str = inst.toString();
// Do something with str
}
?
I don't really care about each instance objecct here, just the string
represenation of each instance, so is it possible to do something like
the following non-valid code (and here I imagine toString() being called
on each element):
for (String str : aListOfSomeClass.toString()) {
// Do something with str
}
Hope I made sense, thanks!
- Fencer