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

String 常用方法

时间:2018-01-13 18:59:46      阅读:122      评论:0      收藏:0      [点我收藏+]

标签:split()   ase   length   常用   log   gpo   长度   wrap   contain   

字符串的常用方法:
1,求字符串的长度
String s = "Hello world!";
int len = s.length();
2.获取字符串中指定位置的字符
s.charAt(0); 这样会得到 H 字符
3.字符串的拼接
s.concat("Hello China"); 相当于 "Hello world!" + "Hello China"
4.字符串转小写 toLowerCase()
5.字符串转大写toUpperCase()
6.字符串替换s.replace("Hello", "Hi")
7.字符串去除首尾空格 s.trim()
8.字符串是否是以指定的字符串开头
s.statWith("Hello");
9.字符串是否是以指定的字符结尾
s.endWith("world");
10. 字符串中是否包含指定字符
s.contains("H")
11.字符串按照指定的字符分割
s.split()

String 常用方法

标签:split()   ase   length   常用   log   gpo   长度   wrap   contain   

原文地址:https://www.cnblogs.com/SunshineLittleCat/p/8279846.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!