Here you can find the source of getNumbersBetweenRange(BigInteger minValue, BigInteger maxValue)
Parameter | Description |
---|---|
minValue | The minimum value of the range |
maxValue | The maximum value of the range |
private static List<BigInteger> getNumbersBetweenRange(BigInteger minValue, BigInteger maxValue)
//package com.java2s; //License from project: Open Source License import java.math.BigInteger; import java.util.ArrayList; import java.util.LinkedList; import java.util.List; public class Main { /**/*from w w w .j a va 2 s. co m*/ * This method generates all integer numbers between the given range * * @param minValue * The minimum value of the range * @param maxValue * The maximum value of the range * @return A list which contains all numbers between the range */ private static List<BigInteger> getNumbersBetweenRange(BigInteger minValue, BigInteger maxValue) { List<BigInteger> numbers; if (maxValue.longValue() > Integer.MAX_VALUE) { numbers = new LinkedList<>(); } else { numbers = new ArrayList<>(); } BigInteger auxiliarNumber = minValue; for (; auxiliarNumber.compareTo(maxValue) < 1; auxiliarNumber = auxiliarNumber.add(BigInteger.ONE)) { numbers.add(auxiliarNumber); } return numbers; } }