Possible Duplicate:
char and int in Java
AsicII table :http://www.asciitable.com
The code below print out the Dec value of the corresponding char, for example "123" -> 49 50 51
public void foo(String str)
{
for(int x = 0; x < str.length(); x++)
{
int temp = str.charAt(x);
System.out.println(temp);
}
}
But I notice java is a strong type language, which mean every thing has to be cast in compile time, but how come the code knows how and when to convert char into the correct Dec value in AsicII table? Did I mess up any of the java/programming fundamental?