From Core Java, vol. 1, 9th ed., p. 69:
The character ℤ requires two code units in the UTF-16 encoding. Calling
String sentence =
Horstmann was talking about the 'Z' which need two UTF-16 code units. Take a look at this code:
public class Main {
public static void main(String[] args)
{
String a = "\uD83D\uDE02 is String";
System.out.println("Length: " + a.length());
System.out.println(a.charAt(0));
System.out.println(a.charAt(1));
System.out.println(a.charAt(2));
System.out.println(a.charAt(3));
}
}
in IntelliJ Idea I can't even paste the 4 byte character as one character because while pasting this emoji: