String类常见的方法

类String

public final class String 

extends Object 

implements Serializable, comparable<String>, CharSequence

String 类代表字符串。Java 程序中的所有字符串字面值(如 "abc" )都作为此类的实例实现。

字符串是常量;它们的在创建之后不能更改。字符串缓冲区支持可变的字符串。 

 

 

 

 

 

 

 

常用方法:

public char charAt(int index)  ==》返回指定位置的字符(0-length()-1);
形象记法: charAt(At在)(int index位置)

在可以看下面的底层源码:return value[index];就是返回字符串指定位置的字符

 

 

 

public boolean startsWith(String prefix)
测试此字符串是否以指定的前缀开始。

public boolean startsWith(String prefix,
                          int toffset)
测试此字符串从指定索引开始的子字符串是否以指定前缀开始。

 

参数:
prefix - 前缀。
toffset - 在此字符串中开始查找的位置。 

























 

 

 

 

 

 

 


 

posted @ 2015-10-07 22:03  宝哥大数据  阅读(259)  评论(0编辑  收藏  举报