文件名称:Demo6
-
所属分类:
- 标签属性:
- 上传时间:2012-11-16
-
文件大小:4.38kb
-
已下载:0次
-
提 供 者:
-
相关连接:无下载说明:别用迅雷下载,失败请重下,重下不扣分!
介绍说明--下载内容来自于网络,使用问题请自行百度
编写一个方法,输出在一个字符串中,指定字符串出现的次数.方法原型为:
public static int countStr(String str1,string str2) -package defalt
public class Hellow {
public static void main(String args[])
{String str1="Hello,it is Tom speaking,who is that?"
String str2="is"
System.out.println(countStr(str1,str2))
}
public static int countStr(String str1,String str2){
int num=0
int indexFrom=0
indexFrom=str1.indexOf(str2,indexFrom)
while(indexFrom!=-1){
num++
indexFrom+=str2.length()
indexFrom=str1.indexOf(str2,indexFrom)
}
return num
}
}
public static int countStr(String str1,string str2) -package defalt
public class Hellow {
public static void main(String args[])
{String str1="Hello,it is Tom speaking,who is that?"
String str2="is"
System.out.println(countStr(str1,str2))
}
public static int countStr(String str1,String str2){
int num=0
int indexFrom=0
indexFrom=str1.indexOf(str2,indexFrom)
while(indexFrom!=-1){
num++
indexFrom+=str2.length()
indexFrom=str1.indexOf(str2,indexFrom)
}
return num
}
}
(系统自动生成,下载前可以参看下载内容)
下载文件列表
Demo6/.classpath
Demo6/.project
Demo6/.settings/org.eclipse.jdt.core.prefs
Demo6/bin/cn/ICompare.class
Demo6/bin/cn/NoStudentException.class
Demo6/bin/cn/Student.class
Demo6/bin/cn/Worker.class
Demo6/src/cn/ICompare.java
Demo6/src/cn/NoStudentException.java
Demo6/src/cn/Student.java
Demo6/src/cn/Worker.java
Demo6/bin/cn
Demo6/src/cn
Demo6/.settings
Demo6/bin
Demo6/src
Demo6
Demo6/.project
Demo6/.settings/org.eclipse.jdt.core.prefs
Demo6/bin/cn/ICompare.class
Demo6/bin/cn/NoStudentException.class
Demo6/bin/cn/Student.class
Demo6/bin/cn/Worker.class
Demo6/src/cn/ICompare.java
Demo6/src/cn/NoStudentException.java
Demo6/src/cn/Student.java
Demo6/src/cn/Worker.java
Demo6/bin/cn
Demo6/src/cn
Demo6/.settings
Demo6/bin
Demo6/src
Demo6
本网站为编程资源及源代码搜集、介绍的搜索网站,版权归原作者所有! 粤ICP备11031372号
1999-2046 搜珍网 All Rights Reserved.