All pastes #547005 Raw Edit

java

public java v1 · immutable
·published 2007-06-07 07:18 UTC
rendered paste body
    public static int [] lengthen(int [] a, int add)    {        int [] b = new int [a.length + add];        for(int i = 0; i < b.length; i++)        {            if(i < a.length)            {                b[i] = a[i];            }            else            {                System.out.println("Called at " + i);                b[i] = 1;            }        }        return b;    }    public static void main(String [] args)    {        int [] dataSet = {5, 2, 9, 11, 0};        int addLength = 10;        int [] x = lengthen(dataSet, addLength);    }/*with some printing stuff I do elsewhere in the code it returns:The original data set is:the length is 55, 2, 9, 11, 0, The lengthen method makes the original data look like this:Called at 5Called at 6Called at 7Called at 8Called at 9Called at 10Called at 11Called at 12Called at 13Called at 14the length is 55, 2, 9, 11, 0, */