I was doing research on concatenating char primitive values to form a String and came across this post:
Concatenate chars to form String in java
I understand that the correct way of producing the final String value is to use the toString() method, how come that if I do not use this method, I still get the same output. I would have thought the following code would output the heap address of the object sb but it still prints 'ice'.
Thank you.
public class CharsToString { public static void main (String args[]) { char a, b, c; a = 'i'; b = 'c'; c = 'e'; StringBuilder sb = new StringBuilder(); sb.append(a); sb.append(b); sb.append(c); System.out.println(sb); } }