The Java char type is 16-bit (UTF-16 encoded), which does not satisfy all Unicode character encodings, and the Java code point refers to the Unicode encoded value corresponding to a character, such as the Unicode code point of a character as u+0041. The number of code points is actually the number of Unicode characters.
Each char variable is actually a unit of code, and a character typically corresponds to a unit of code or multiple code units.
The length method of the string returns the number of code units (note, not the number of characters), and the Codepointcount method returns the number of code points, which is the number of Unicode characters.
When compiling Java source code, Javac's-encoding option can specify the encoding used by the source code character file, because if this option is not added, Javac chooses a default encoding assumed to be the encoding of the source file, but cannot be compiled if the assumed encoding does not match the actual encoding of the file. In many code scenarios, coding-related operations involve the default encoding, so do not rely on the default encoding, which indicates that a stream's encoding is always right in the code.
About Java code points and code units