字符串的应用

来源:互联网 发布:最优化文章 编辑:程序博客网 时间:2024/06/05 01:58

进步无论大小都是让人开心的事情。。。


public class Test1 {


public static void main(String[] args) {
// TODO Auto-generated method stub
 String str="Hello Word";
 System.out.println("字符串的长度"+str.length());
 System.out.println("字符o在字符串中第一次出现的位置"+str.indexOf("o"));
 System.out.println("字符o在字符串中最后一次出现的位置"+str.indexOf("o"));
 System.out.println(str);
 System.out.println(""+str.replace("l","m"));
 String[] sp=str.split(" ");
 System.out.println(sp[0]);
 System.out.println(sp[1]);
 System.out.println(sp[1].equals(sp[0]));
 }
}

0 0
原创粉丝点击