String类常用
来源:互联网 发布:mac虚拟机免费版下载 编辑:程序博客网 时间:2024/06/05 14:54
public char charAt(int index)//charAt() 方法用于返回指定索引处的字符。索引范围为从 0 到 length() - 1。//返回值//返回指定索引处的字符。int compareTo(Object o)//或int compareTo(String anotherString)//compareTo() 方法用于两种方式的比较://字符串与对象进行比较。//按字典顺序比较两个字符串。//返回值//如果参数字符串等于此字符串,则返回值 0;//如果此字符串小于字符串参数,则返回一个小于 0 的值;//如果此字符串大于字符串参数,则返回一个大于 0 的值。public int indexOf(int ch)://返回指定字符在字符串中第一次出现处的索引,如果此字符串中没有这样的字符,则返回 -1。public int indexOf(int ch, int fromIndex)://返回指定字符在字符串中第一次出现处的索引,如果此字符串中没有这样的字符,则返回 -1。int indexOf(String str)://返回指定字符在字符串中第一次出现处的索引,如果此字符串中没有这样的字符,则返回 -1。int indexOf(String str, int fromIndex)://返回指定字符在字符串中第一次出现处的索引,如果此字符串中没有这样的字符,则返回 -1。//返回值//指定子字符串在字符串中第一次出现处的索引,从指定的索引开始。public String[] split(String regex,int limit)//返回值//成功则返回替换的字符串,失败则返回原始字符串。 public String substring(int beginIndex)//或public String substring(int beginIndex, int endIndex)//参数//beginIndex -- 起始索引(包括)。//endIndex -- 结束索引(不包括)。//返回值//子字符串。public char[] toCharArray()//返回值//字符数组。toCharArray() 方法将字符串转换为字符数组。public String trim()//返回值//删除头尾空白符的字符串。public String replace(char oldChar,char newChar)//参数//oldChar -- 原字符。//newChar -- 新字符。//返回值//替换后生成的新字符串。public byte[] getBytes(String charsetName) throws UnsupportedEncodingException//或public byte[] getBytes()//参数//charsetName -- 支持的字符集名称。//返回值//返回 byte 数组。//getBytes(String charsetName):使用平台的默认字符集将字符串编码为 byte 序列,并将结果存储到一个新的 byte 数组中。//getBytes(): 使用平台的默认字符集将字符串编码为 byte 序列,并将结果存储到一个新的 byte 数组中。
参考:
菜鸟教程
字符串与String类
0 0
- 常用类----String类
- 常用类--String
- String类常用方法
- string类常用操作
- String类常用方法
- string 类常用函数
- 系统常用类String
- STL常用string类
- javaSE-常用类-String
- String类常用功能
- 常用类String
- String类常用方法
- String类常用方法
- String 类常用方法
- String类 常用方法
- String类常用方法
- String类常用方法
- 常用类String
- 吐个槽 Spring Data Elasticsearch 3.0M1还不支持Elasticsearch 5.X
- VMWare安装黑苹果
- Service入门(一)——startService、stopService
- spring MVC maven等整合
- nexus批量更新jar包
- String类常用
- 前端日记 #1 - 开发工具及基本概念
- 节点
- 经典编程书籍大全
- Django 官方文档write your first Django app --7
- 洛谷1181数列分段Section I
- main( intmain(int argc,char *argv[]) argc ,char*argv[ ] )
- IntelliJ IDEA 设置 编辑器字体大小背景色及快捷键
- C++Primer第五版 第六章习题答案(21~30)