Why is StringBuilder.toString() returning new String instances for empty strings ? (original) (raw)
Jan Ohlsen jan.t.ohlsen at gmail.com
Thu Feb 28 07:47:40 UTC 2013
- Previous message: hg: jdk8/tl/jdk: 8008785: IdentityHashMap.values().toArray(V[]) broken by JDK-8008167
- Next message: Why is StringBuilder.toString() returning new String instances for empty strings ?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
System.out.println( new StringBuilder().toString() == "" ); -> "false"
Any reason for not returning the "" instance?
public String toString() {
return new String(value, 0, count);
}
-->
public String toString() {
return (count > 0) ? new String(value, 0, count) : "";
}
?
- Previous message: hg: jdk8/tl/jdk: 8008785: IdentityHashMap.values().toArray(V[]) broken by JDK-8008167
- Next message: Why is StringBuilder.toString() returning new String instances for empty strings ?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]