This is because, for some strange reason, java treats char as short. Your expression "1" is a constant expression of type char. It is stored internally as some numerical value. Usually everything is fine with this approach, for example, System.out.println('1') will print exactly what you expect.
But when you write int a = '1'; , char is converted to int because char behaves like a short int there.
PS: if there was no implicit conversion between char and int (which in any case does not make sense), you received a compilation error.
talex source share