Java tutorial
//package com.java2s; /* Copyright 2004 - 2007 Kasper Nielsen <kasper@codehaus.org> Licensed under * the Apache 2.0 License, see http://coconut.codehaus.org/license. */ import java.util.ArrayList; import java.util.Collection; import java.util.Collections; import java.util.List; public class Main { public static Collection<Integer> seq(int start, int stop) { List<Integer> l = new ArrayList<Integer>(Math.abs(stop - start)); for (int i = Math.min(start, stop); i <= Math.max(start, stop); i++) { l.add(i); } if (stop < start) Collections.reverse(l); return l; } }