全部题库 / Java / 试题详情
简答题 Java
2013-07-30

本题是判断一个字符串“Tom”是否在另外一个字符串 “I am Tom,I am from China”中出现。
public class javal{
public static void main(String[]args){
         ;
strl="I am Tom,I am from China.";
str2="Tom";
int i=         ;
if(         )
System.out.println("\"+str2+"\"is in the
string:\""+strl+"\"");
else
System.out.println("\""+str2+"\"is not in the
string:\""+strl+"\"");
} 
}

参考答案

暂无

答案解析

第1处:String strl,str2
第2处:strl.indexOf(str2)
第3处:i!=-1
【解析】第1处使用前定义变量strl和str2;第2处和第3处判断str2是否是strl的子串。

你可能感兴趣的试题