java技术博客

jsp博客
数据加载中……
FindSubstring.java
/**
*查找特定的子串
*/
public class FindSubstring{
public static void main(String[] args){
String str="Welcome the body.";
System.out.println("Find the substring boy occurrence:"+str.indexOf("boy"));//查找子串
System.out.println("Find the substring by occurrence: "+str.indexOf("by"));//查找子串
System.out.println("Find the char t occurrence: "+str.indexOf('t'));//查找特定的字符
System.out.println("Test the string begin with wel.:"+str.startsWith("wel"));//是否以"wel"开始
System.out.pritnln("Test the string end with body.:"+str.endWith("boy"));//是否以"boy"结束
}
}

posted on 2008-10-22 13:06 郭兴华 阅读(190) 评论(0)  编辑  收藏


只有注册用户登录后才能发表评论。


网站导航: