有序的整型数组(升序),给定一个数,两数相加返回true,否则返回false

  public static boolean sum2(int ary[], int sum) {
        int start = 0;
        int end = ary.length - 1;

        for (; start < end; ) {
            if (ary[start] + ary[end] == sum) {
                return true;
            } else if (ary[start] + ary[end] > sum) {//大于时,end左移动
                end--;
            } else {//小于的情况
                start++;
            }
        }
        return false;
    }
原文地址:https://www.cnblogs.com/zzq-include/p/14122087.html