String All Methods
生活随笔
收集整理的這篇文章主要介紹了
String All Methods
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
1、public char charAt(int index)
1 public class Test{ 2 public static void main(String args[]){ 3 String s="hello world!";//返回這個字符串的指定索引處的char值 4 char c0=s.charAt(0);//第一個char值的索引為0. 5 //char c1=s.charAt(20); 6 //IndexOutOfBoundsException拋出異常,index參數為負或不小于該字符串的長度. 7 System.out.println(c0); 8 } 9 }?
2、public int codePointAt(int index)
1 public class Test{ 2 public static void main(String args[]){ 3 String s="hello world!";//返回指定索引處的字符(Unicode代碼點) 4 int i=s.codePointAt(0);//其范圍從0到length()-1 5 System.out.println(i); 6 } 7 }?
轉載于:https://www.cnblogs.com/MazeHong/p/5803482.html
總結
以上是生活随笔為你收集整理的String All Methods的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: p:commandButton vs h
- 下一篇: 亳州有什么特色小吃?