码迷,mamicode.com
首页 > 其他好文 > 详细

String All Methods

时间:2016-08-24 17:18:20      阅读:177      评论: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
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!