简答题 Java
题号 #2244586

本题是判断一个字符串“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的子串。

你可能感兴趣的试题

找试题 · 找答案 · 找资料 在线模考