i've a List<Polygon> polygons
, where Polygon represents the geojson concept of polygon. In the class Polygon i defined a method toGeojson()
that returns a string containing the geojson representation. I'd like to print all the list in a compact way instead of doing this:
String result = '';
for(Polygon p: polygons)
result += p.toGeojson();
I could do result = p.toString()
but i cannot use toString()
method because i use it for an other thing. Is there a way to call toGeojson()
on a List just as you'd do with toString()
?