Example usage for java.lang Integer MAX_VALUE

List of usage examples for java.lang Integer MAX_VALUE

Introduction

In this page you can find the example usage for java.lang Integer MAX_VALUE.

Prototype

int MAX_VALUE

To view the source code for java.lang Integer MAX_VALUE.

Click Source Link

Document

A constant holding the maximum value an int can have, 231-1.

Usage

From source file:Main.java

static int getMaximumMemory() {
    long maxMem = RUNTIME.maxMemory();

    if (maxMem > Integer.MAX_VALUE) {
        return Integer.MAX_VALUE;
    }/*ww  w. ja  va2 s .c o m*/

    return (int) maxMem;
}

From source file:Main.java

/**
 * Will iterate through an array will get min
 * //from   w ww .  j  av a 2 s  .  c o  m
 * @param arr
 * @return min from the arr
 */
public static int getMin(int[] arr) {
    int min = Integer.MAX_VALUE;
    for (int i = 1; i < arr.length; i++)
        if (arr[i] < min)
            min = arr[i];
    return min;
}

From source file:Main.java

public static void calcViewMeasure(View view) {

    int width = View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED);
    int expandSpec = View.MeasureSpec.makeMeasureSpec(Integer.MAX_VALUE >> 2, View.MeasureSpec.AT_MOST);
    view.measure(width, expandSpec);//  w  ww . j ava2 s.c  om
}

From source file:Main.java

public static void expandTreeNode(JTree tree, DefaultMutableTreeNode node) {
    expandTreeNode(tree, node, Integer.MAX_VALUE);
}

From source file:Main.java

public static Size getMinimumSize(List<Size> sizes) {
    if (sizes == null || sizes.size() == 0)
        return null;
    int minArea = Integer.MAX_VALUE;
    Size minSize = null;/*w  ww . j a  v  a 2 s.  com*/
    for (Size e : sizes) {
        int area = e.width * e.height;
        if (area < minArea) {
            minArea = area;
            minSize = e;
        }
    }
    return minSize;
}

From source file:Main.java

private static int getClosestResampleSize(int cx, int cy, int maxDim) {
    int max = Math.max(cx, cy);

    int resample = 1;
    for (resample = 1; resample < Integer.MAX_VALUE; resample++) {
        if (resample * maxDim > max) {
            resample--;/*ww  w.  j  ava  2 s  .  com*/
            break;
        }
    }

    if (resample > 0) {
        return resample;
    }
    return 1;
}

From source file:Main.java

public static <T> int longestCommonPrefix(List<List<T>> paths) {
    int[] lengths = new int[paths.size()];
    int minLength = Integer.MAX_VALUE;
    for (int i = 0; i < paths.size(); ++i) {
        int len = paths.get(i).size();
        lengths[i] = len;/*  w  w  w .  j  a v  a2s . c o m*/
        if (len < minLength)
            minLength = len;
    }

    int longestCommonPrefix = 0;
    while (longestCommonPrefix < minLength) {
        List<T> headPath = paths.get(0);
        for (List<T> path : paths) {
            if (!headPath.get(longestCommonPrefix).equals(path.get(longestCommonPrefix))) {
                return longestCommonPrefix;
            }
        }
        ++longestCommonPrefix;
    }
    return longestCommonPrefix;
}

From source file:Main.java

public static BlockingQueue<Runnable> makeQueue(Integer capacity) {
    if ((capacity == null) || (capacity <= 0) || (capacity == Integer.MAX_VALUE)) {
        return new LinkedBlockingQueue<Runnable>();
    } else {/*from   w w w .  ja v  a 2  s  .c  o  m*/
        return new ArrayBlockingQueue<Runnable>(capacity);
    }
}

From source file:Main.java

protected static void do_ints() {
    int i = Integer.MAX_VALUE;
    System.out.println("i=" + i++);
    System.out.println("i=" + i++);
    System.out.println("i=" + i++);
}

From source file:Main.java

public static void calcViewMeasure(View view) {
    int width = MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED);
    int expandSpec = MeasureSpec.makeMeasureSpec(Integer.MAX_VALUE >> 2, MeasureSpec.AT_MOST);
    view.measure(width, expandSpec);/*from   www .  ja v  a 2  s.c o m*/
}