字符串操作
来源:互联网 发布:淘宝cos店 三 编辑:程序博客网 时间:2024/06/04 00:34
package welcome;public class 字符串操作 {public static void main(String[] args) {// TODO Auto-generated method stub//关于字符串大小的比较String s1 = "abc";String s2 = "abad";System.out.println(s1.compareTo(s2));//访问字符串里的字符System.out.println(s1.charAt(2));//遍历字符串for(int i = 0; i < s1.length(); i++){System.out.println(s1.charAt(i));}System.out.println();//遍历子串String s3 = "012345B67839汉字";System.out.println(s3.substring(2));System.out.println(s3.substring(2, 4));//寻找位置System.out.println(s3.indexOf('4'));System.out.println(s3.indexOf('A'));System.out.println(s3.indexOf("B67"));System.out.println();//寻找第二次出现的‘3’int loc = s3.indexOf('3');System.out.println(s3.indexOf('3',loc+1));System.out.println();//不变的字符串String s4 = "abcd";String s5 = s4.toUpperCase();System.out.println(s4);System.out.println(s5);System.exit(0); //注意此种避免错误的方法}}
阅读全文
0 0
- 字符串操作
- 字符串操作
- 操作字符串
- 字符串操作
- 字符串操作
- 字符串操作
- 字符串操作
- 字符串操作
- 字符串操作
- 字符串操作
- 字符串操作
- 字符串操作
- 字符串操作
- 字符串操作
- 字符串操作
- 字符串操作
- 字符串操作
- 字符串操作
- OpenCV Canny边缘检测
- c#七层 登录版
- 《弃子长安》第十五章 人断惊崖
- Eclipse设置新建jsp文件默认模板
- python中实现一个socket和server的程序
- 字符串操作
- MyBatis框架环境变量配置及简单使用教程
- Spring的AOP讲解
- 自定义阶梯式布局
- keystone时使用openstack命令创建时报错Discovering versions from the identity service failed when creating the p
- HDU 4970-Killing Monsters
- AndroidStudio Plugins 开发流程
- 写给女儿的一封信
- 梯度下降法(Gradient Descent)概述