字符串的最常用操作
来源:互联网 发布:linux命令启动sh脚本 编辑:程序博客网 时间:2024/06/03 22:33
package lz.test.stringoperation;
public class StringOperation {
public static void main(String[] args) {
String testStr = "http://lz881228.blog.163.com";
//获取指定位置字符
System.out.println(testStr.charAt(4));
//获取字符子串.从第4位开始截取,到最后
System.out.println(testStr.substring(4));
//截取字符子串。从第2位开始到第5位之前的字符串
System.out.println(testStr.substring(2,5));
//替换字符。
System.out.println(testStr.replace("//", "\\"));
//得到字符串的哈希码
System.out.println(testStr.hashCode());
//获得字符所在的位置
System.out.println(testStr.indexOf("!"));
//如果不存在会返回-1
System.out.println(testStr.indexOf("$"));
//截取叹号后面的字符串
System.out.println(testStr.substring(testStr.indexOf("!")+1));
//字符串转化为字符数组
char[] strC = testStr.toCharArray();
for (char c : strC) {
System.out.print(c+"_");
}
//字符串转成数组
String str = "" ;
for(int i=0;i<4000;i++){
str += "天童" + ",";
strList.add(str);
}
String [] strArray = str.split(",");
System.out.println();
//返回字符串中指定符号的下标值
testStr = "lz881228.doc";
System.out.println(testStr + ":" + testStr.lastIndexOf("."));
}
}
0 0
- 字符串的最常用操作
- ios 最全的常用字符串操作
- ios 最全的常用字符串操作
- 字符串的常用操作
- 常用的字符串操作
- 处理字符串的常用操作
- C#字符串的常用操作
- C#字符串的常用操作
- C#字符串的常用操作
- JAVA常用的字符串操作
- C# 常用的字符串操作
- C#字符串的常用操作
- ios 常用字符串的操作
- 几个常用的字符串操作
- ios 常用字符串的操作
- ios 常用字符串的操作
- ios 常用字符串的操作
- ios 常用字符串的操作
- JS创建类和对象
- spring bean 加载顺序
- Ant构建工具的使用
- 写代码不能不写注释
- JHTP小结_第二章_Java应用、输入、输出及运算符简介
- 字符串的最常用操作
- 字符串转为数字(c c++ 两种方式)
- 【转载】浪漫交谊舞曲连播481首(原编)
- 动态代理(1,umeng 自定义事件的统计,2,非侵入式的性能测量方法 )
- JS 从URL获取参数方法
- JQuery中根据属性或属性值获得元素
- Ext获取表单中列行值
- Docker 网络(十三)—— Calico for Docker
- Extjs 等待提示的几种方式