zoukankan      html  css  js  c++  java
  • 在数组中查找指定的值

    public class BreakDemo {
        public static void main(String[] args) {

            int[] arrayOfInts = { 32, 87, 3, 589, 12, 1076,
                                  2000, 8, 622, 127 };
            int searchfor = 12;

            int i = 0;
            boolean foundIt = false;

            for ( ; i < arrayOfInts.length; i++) {
                if (arrayOfInts[i] == searchfor) {
                    foundIt = true;
                    break;
            }
            }

            if (foundIt) {
                System.out.println("Found " + searchfor + " at index " + i);
            } else {
                System.out.println(searchfor + "not in the array");
            }
        }
    }

  • 相关阅读:
    python函数及模块
    Python分支结构及循环结构
    python基本的知识
    11.21学习总结
    进度日报28
    进度日报27
    进度日报26
    进度日报25
    进度日报24
    11.14学习总结
  • 原文地址:https://www.cnblogs.com/elite-2012/p/3198260.html
Copyright © 2011-2022 走看看