集册 Java实例教程 继续下一个迭代

继续下一个迭代

欢马劈雪     最近更新时间:2020-01-02 10:19:05

593
提示:您可在线编辑运行本教程的实例 - 运行实例,去试试!
继续下一个迭代

class ContinueDemo {

    public static void main(String[] args) {/*来 自 n o w j a   v  a . c o m - 时  代  Java*/


        String searchMe = "peter piper picked a "

                + "peck of pickled peppers";

        int max = searchMe.length();

        int numPs = 0;


        for (int i = 0; i < max; i++) {

            // interested only in p's

            if (searchMe.charAt(i) != 'p')

                continue;


            // process p's

            numPs++;

        }

        System.out.println("Found " + numPs + " p's in the string.");

    }

}


展开阅读全文