首页 > 其他 > 详细

String All Methods

时间:2016-08-24 17:16:09      阅读:180      评论:0      收藏:0      [点我收藏+]

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 }

 

String All Methods

原文:http://www.cnblogs.com/MazeHong/p/5803482.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!