Q:

When converting a char to a int in JAVA, why is no cast necessary?

In Java I know you can convert char to ints like so:
int c = (int) msg.charAt(i);

But why does this also work with no errors:
int c = msg.charAt(i);

the function returns an int, so surely it needs to be "cast" to an int before using it.
DUPLICATE: Although the answer given by: Why are we allowed to assign char to a int in java? , the qusestion is slightly different. As I was not asking why we can assign a char to an int, rather I was asking why no cast is necessary. I'll suggest to keep this open for people on Google, even though its the same answer!

A:

String.charAt returns char. char to int is a widening primitive conversion (see JLS 5.1.2), this type of conversion does not lose information so it does not need an explicit cast

