Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Fixed
-
2.0.5
-
None
-
Mac
Description
The folowing Java code:
public class HelloWorld { private String[] names; public String[] getNames() { return names; } public void setNames(String... names) { this.names = names; } public String toString() { return "Hello " + join(getNames()); } private String join(String[] strings) { StringBuilder sb = new StringBuilder(); String delim = ""; for(String string : strings) { sb.append(delim).append(string); delim = ", "; } return sb.toString(); } public static void main(String[] args) { HelloWorld helloWorld = new HelloWorld(); helloWorld.setNames("Morten", "Riccardo", "Anders"); System.out.println(helloWorld.toString()); } }
produces the same output when compiled in Java or in Groovy 1.8.8 (the names joined with commas), but in Groovy 2.0.5 it produces: Hello [Ljava.lang.String;@4e5a67df
Found while trying to demonstrate how to simplify Java code in Groovy (not very cool...)