+ 7

What is the default value of elements in char array in java

For eg: char ch []=new char[1]; System.out.println(ch[i]); I got output as blank(nothing)

25th Dec 2017, 1:27 PM
Rstar
Rstar - avatar
2 Answers
+ 5
Well assuming you have not added anything into the array by assigning the first position (0) a value, it will be null. Because it is a char array the default value for char is '\u0000' but I am not sure if this is carried over for the array.
25th Dec 2017, 1:56 PM
Tarantino
Tarantino - avatar
+ 2
the position 0 contents one char null
26th Dec 2017, 9:09 PM
Hazzael Reyes Castellanos
Hazzael Reyes Castellanos - avatar