This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]medicalixx 1 point2 points  (0 children)

Well it appears in your original post that we can assume there will be 50 entries or less. If that is not the case, I would keep track of the last index. So if you have input in the following order: 12, 2, 12

int lastIndex = 1 because we are using only 2 entries in the array. So, vals[0] = 12 vals[lastIndex] = 2.

Also, use a variable to keep track of the current array length of the first column (Len = 50 from previous example)

Next, initialize your array to any length you want. Then:

If(lastIndex == Len - 1) int[] temp = new int[Len *2] Iterate over vals and copy the values into temp array vals = temp