Hi friends,
For the following arrays created below, I couldn't able to come to a conlusion why the ouput is like this. Can any one please clear my dilemma on this.
char[] c = new char[0];
System.out.print(c);//The ouput is empty. Why dont it call toString()?
System.out.print(c.toString());//prints hexcode of the array
System.out.print("hi"+c);//for this toString()is getting called
int[] i = new int[0];
System.out.print(i);//The hashCode is printed. Does it calls toString() on this by default?. If yes why it is not called for character arrays?
String str = new String();
System.out.print(str)//The output is empty
System.out.print(str.toString())//The output is still showing as empty.
String[] str1 = new String[0];
System.out.print(str1);//prints the hashcode
Thanks,
Ravindra.