public static void addRange(Collection<Integer> c, int start, int to, int step)
    {
        if(step <= 0)
            throw new RuntimeException("Would create an infinite loop");
        
        for(int i = start; i < to; i+= step)
            c.add(i);
    }
public static void addRange ( Collection < Integer > c , int start , int to , int step ) { if ( step <= 0 ) throw new RuntimeException ( "Would create an infinite loop" ) ; for ( int i = start ; i < to ; i += step ) c . add ( i ) ; }
Adds values into the given collection using integer in the specified range and step size.
If the <tt>start</tt> value is greater or equal to the <tt>to</tt> value, nothing will
be added to the collection.

@param c the collection to add to
@param start the first value to add, inclusive
@param to the last value to add, exclusive
@param step the step size.
@throws RuntimeException if the step size is zero or negative.