How to declare a character array in Java?

To declare a character array in Java, do this: char array[] = { 'H', 'e', 'l', 'l', 'o' };.

You can declare either a prefilled one or an empty one that you can fill later:

char prefilledArray[] = { 'H' , 'e' , 'l' , 'l' , 'o' };
char emptyArray[] = new char[5];

System.out.println(prefilledArray); // Hello
System.out.println(emptyArray); // 

emptyArray[0] = 'W';
emptyArray[1] = 'o';
emptyArray[2] = 'r';
emptyArray[3] = 'l';
emptyArray[4] = 'd';

System.out.println(emptyArray); // World