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