printing of array of characters vs printing out of numerical(primitive)arrays
Code :
int[] numSeq = {1,2,3};
System.out.println(numSeq);
Code :
char[] nameSeq = {'J','a','v','a'};
System.out.println(nameSeq);
why does the output of a NUMERICAL primitive array is different from printing a CHARACTER primitive array?, the current knowledge that i have right now is that the first code, when the int array is being called in a print statement, it returns the memory address from where it was created, but why does the second code, a character array is being printed/treated just like a simple String object? but the call is just the same..
Re: printing of array of characters vs printing out of numerical(primitive)arrays
Read the API doc for java.lang.Object.toString() for the format of toString() if you don't override it. For printing arrays there are a couple of handy methods in java.util.Arrays: toString(<type>[]) and toDeepString(<type>[]). I suspect the char[] is being automagically promoted to a String somehow.