Hôm nay mình sẽ giới thiệu cho các bạn về lấy unicode của một chuỗi strinh trong java, các bạn có thể xem ví dụ bên dưới.

Sử dụng phương thức codePointBefore() trong Java để trả về ký tự (mã Unicode) ở trước index đã cho.
public class StringUniCode{
public static void main(String[] args){
String test_string="Welcome to TutorialsPoint";
System.out.println("String under test is = "+test_string);
System.out.println("Unicode code point at"
+" position 5 in the string is = "
+ test_string.codePointBefore(5));
}
}
Kết quả:
String under test is = Welcome to TutorialsPoint
Unicode code point at position 5 in the string is =111
No comments:
Post a Comment