| Summary: | [toString] Source -> Generate toString() fails for String[][] | ||
|---|---|---|---|
| Product: | [Eclipse Project] JDT | Reporter: | Paul Nahay <pnahay> |
| Component: | UI | Assignee: | JDT-UI-Inbox <jdt-ui-inbox> |
| Status: | CLOSED NOT_ECLIPSE | QA Contact: | |
| Severity: | normal | ||
| Priority: | P3 | CC: | julian.honnen, noopur_gupta, paul-eclipse |
| Version: | 4.16 | ||
| Target Milestone: | --- | ||
| Hardware: | All | ||
| OS: | All | ||
| Whiteboard: | |||
That works as expected. The unbalanced brackets are from the toString() of the inner arrays:
{"one", "two"}.toString() => "[Ljava.lang.String;@2f92e0f4"
There's no Arrays::toString alternative for nested arrays in the JDK, so you'd have to implement your own.
|
Source -> Generate toString() fails for String[][]. A toString() method IS generated, but it is malformed. See code, and output, which is a string that has 4 left brackets in it, but only 2 matching right brackets. import java.util.Arrays; public class GenerateToStringBug { public static void main(String[] args) { System.out.println(new GenerateToStringBug()); } String[][] array = {{"one", "two"}, {"three", "four"}}; @Override public String toString() { return "GenerateToStringBug [array=" + Arrays.toString(array) + "]"; // OUTPUT: GenerateToStringBug [array=[[Ljava.lang.String;@2f92e0f4, [Ljava.lang.String;@28a418fc]] } }