Extract Ascii codes from a String in Java
Description
The following code shows how to extract Ascii codes from a String.
Example
//w w w .j a v a 2 s .co m
public class Main {
public static void main(String[] args) throws Exception {
String test = "ABCD";
for (int i = 0; i < test.length(); ++i) {
char c = test.charAt(i);
System.out.println((int) c);
}
}
}
The code above generates the following result.
Home »
Java Tutorial »
Java Data Type »
Java Tutorial »
Java Data Type »