Java - What is the output, int + char

What is the output of the following code.

Description

What is the output of the following code.

public class Main{

  public static void main(String[] args) {


    System.out.println(5+"a");
    System.out.println(5+'a');
    System.out.println('5'+'a');
  }
}


Click to view the answer

5a
102
150

Note

The ASCII code for letter a is 97.

During the addition, char is converted to int.

Related Topic