Here you can find the source of range(String second, String first)
private static String range(String second, String first)
//package com.java2s; //License from project: Open Source License public class Main { private static String range(String second, String first) { try {// w w w . j a v a 2 s. co m int from = Integer.parseInt(first); int to = Integer.parseInt(second); if (from > to) { int temp = from; from = to; to = temp; } else if (from == to) return String.valueOf(from); StringBuilder sb = new StringBuilder(String.valueOf(from)); for (int i = from + 1; i <= to; ++i) sb.append(',').append(i); return sb.toString(); } catch (NumberFormatException e2) { throw new IllegalArgumentException(first + " .. " + second); } } }