📄 continuewitchlabledemo.java
字号:
package pro;
public class ContinueWitchLableDemo {
public static void main(String[] args) {
String s = "abcde feghikl";//字符串
String s2 = "de f";//要查找的字符串
boolean FondIt = false;//用来判断是否查找到s1中包含 字符串 s2
int Max = s.length() - s2.length();//用来设置查找的次数
test: //for循环的标签
for(int i = 0; i <= Max ; i++)
{
int n = s2.length();//取得要查找的字符串S2的长度
int j = i;//设置S字符串中开始查找的首字符的位置
int k = 0;//设置S2字符串中要查找的首字符的位置
while (n-- != 0)//使用要查找的字符串S2的长度做为判断的条件
{
//判断S字符串中和第j个字符是否不同于s2字符串中的第k个字符
if (s.charAt(j++) != s2.charAt(k++))
{
continue test;//如果条件成功,将跳回for循环
}
}
FondIt = true;//如果在S字符中中找到和S2字符串相同内容后,设置为true
break test;//跳出for循环
}
//通过FondIt的值,来判断输入的结果
System.out.println(FondIt ? "Fond It!" : "Dion't Fond It!");
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -