⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 continuewithlabeldemo.java

📁 Java样例程序集合:2D
💻 JAVA
字号:
/**  * ContinueWithLabelDemo.java is an application that compiles * and runs under J2SE 5.0. It requires no other files. *  * The purpose of this example is to demonstrate the continue * statement, NOT to show how to search. In a real program, * you'd probably use the String method indexof(String, int).  */public class ContinueWithLabelDemo {    public static void main(String[] args) {        String searchMe = "Look for a substring in me";        String substring = "sub";        boolean foundIt = false;        int max = searchMe.length() - substring.length();      test:        for (int i = 0; i <= max; i++) {            int n = substring.length();            int j = i;            int k = 0;            while (n-- != 0) {                if (searchMe.charAt(j++) != substring.charAt(k++)) {                    continue test;                }            }                foundIt = true;            break test;        }        System.out.println(foundIt ? "Found it" : "Didn't find it");    }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -