Strings In Depth3 / 18
Up next

Iterate characters

class Main {
    public static void main(String[] args) {
        String s = "abc";
        for (char c : s.toCharArray()) {
            // a char is a UTF-16 code unit; cast to int for its code
            System.out.println(c + " " + (int) c);
        }
    }
}
What you're solving

toCharArray and code points