So I was just wondering if there was a way to print out multiple char variables in one line that does not add the Unicode together that a traditional print statement does.
For example:
char a ='A';
char b ='B';
char c ='C';
System.out.println(a+b+c); <--- This spits out an integer of the sum of the characters
System.out.println(a+""+b+""+c);
or:
System.out.printf("%c%c%c\n", a, b, c);
You can use one of the String constructors, to build a string from an array of chars.
System.out.println(new String(new char[]{a,b,c}));
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With