Looking to get a head start on your next software interview? Pickup a copy of the best book to prepare: Cracking The Coding Interview!
The `codePointAt()` method takes an index as an argument and returns the Unicode value of the character at that index. It can handle characters outside the Basic Multilingual Plane (BMP) as well, unlike the `charAt()` method.
Here’s an example code snippet that demonstrates the usage of `codePointAt()`:
String str = "Hello, World!";
int unicodeValue = str.codePointAt(1);
In this example, we have a string “Hello, World!” and we are using the `codePointAt()` method to get the Unicode value of the character at index 1, which is ‘e’. The output of this code will be 101, which is the Unicode value of ‘e’.