- Java程式設計示例
- 示例 - 主頁
- 示例 - 環境
- 示例 - 字串
- 示例 - 陣列
- 示例 - 日期和時間
- 示例 - 方法
- 示例 - 檔案
- 示例 - 目錄
- 示例 - 異常
- 示例 - 資料結構
- 示例 - 集合
- 示例 - 網路
- 示例 - 多執行緒
- 示例 - 小程式
- 示例 - 簡單GUI
- 示例 - JDBC
- 示例 - 正則表示式
- 示例 - Apache PDF Box
- 示例 - Apache POI PPT
- 示例 - Apache POI Excel
- 示例 - Apache POI Word
- 示例 - OpenCV
- 示例 - Apache Tika
- 示例 - iText
- Java教程
- Java - 教程
- Java實用資源
- Java - 快速指南
- Java - 實用資源
如何使用Java確定字串中的Unicode程式碼點
問題描述
如何確定字串中的Unicode程式碼點?
解決方案
本示例展示瞭如何使用codePointBefore()方法返回指定索引之前的字元(Unicode程式碼點)。
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));
}
}
結果
以上程式碼示例將產生以下結果。
String under test is = Welcome to TutorialsPoint Unicode code point at position 5 in the string is =111
java_strings.htm
廣告