YOUR AD GOES HERE

Java char + char trap: why does 'A' + 'B' print 131? #Shorts #java #programming

Published 23, Nov 2026


Description:
Can you guess the output before the countdown ends?

String a = "A" + 'B' + 'C';
String b = 'A' + 'B' + "C";
System.out.println(a + " " + b);

Answer: ABC 131C

Java evaluates left to right. char + char is int math (65 + 66 = 131), but once a String is involved it concatenates.

Follow Code Snap for a new coding question every day.

#java #javaprogramming #coding #programming #codingquiz #Shorts

Releted More Videos

  • Sorry!!! Nothing to show

You May Also Like

YOUR AD GOES HERE

YOUR AD GOES HERE