西安做网站推广,网站充值平台怎么做,佛山网站设计专业,wordpress主题 q9主题java中的标签大多是为循环设计的#xff0c;是为了在多重循环中方便break和coutinue的使用。
示例#xff1a;在循环中跳到指定的标签处
完整代码
public class Main {public static void main(String[] args) {String strSearch My name is zsh.;String sub…java中的标签大多是为循环设计的是为了在多重循环中方便break和coutinue的使用。
示例在循环中跳到指定的标签处
完整代码
public class Main {public static void main(String[] args) {String strSearch My name is zsh.;String substring zsh;boolean found false;int max strSearch.length() - substring.length();testlbl:for (int i 0; i max; i) {int length substring.length();int j i;int k 0;while (length-- ! 0) {if(strSearch.charAt(j) ! substring.charAt(k)){continue testlbl;}}found true;break testlbl;}if (found) {System.out.println(发现子字符串。);}else {System.out.println(字符串中没有发现子字符串。);}}
}结果输出
发现子字符串。