Return a range Of int between two Min and Max, return a List<String> - Java java.util

Java examples for java.util:List Creation

Description

Return a range Of int between two Min and Max, return a List<String>

Demo Code


//package com.java2s;
import java.util.ArrayList;
import java.util.List;

public class Main {
    public static void main(String[] argv) {
        int i = 42;
        int j = 42;
        System.out.println(rangeOf(i, j));
    }// w  w  w .  j a va  2 s  . co  m

    public static List<Integer> rangeOf(int i, int j) {
        final List<Integer> set = new ArrayList<Integer>(j - i);
        for (int c = i; c < j; c++) {
            set.add(c);
        }
        return set;
    }
}

Related Tutorials