String c="12345";
for(char k:c.toCharArray())
System.out.print(k+4);
This program outputs: 5354555657
I don't really understand why this is out putting those numbers. The only pattern I see is that it prints a "5" then takes the "1" from the string and adds 2 to make "3". Then prints a "5" then takes the "2" from the string and adds 2 to make "4" then prints a "5" and so on.
charcan be treated as numeric value, representing its index in Unicode Table. Also in Javachar + int = intwhich means that when we end up with'1'+4it is evaluated as49(index of character'1') incremented by4which is53.