Question: Here's what the layout is

```
index   num 
0      [10]
1      [20]
2      [30]
 (Add 35 here)
3      [40] Move elements down
4      [50]
5      [60]
6      [70]

```

then my method is this

```
public static void method(int[] num, int index, int addnum)
{

}

```

How can i add 35 in there?

Tried this:

```
public static void method(int[] num, int index, int addnum)
{
int index = 10;
for(int k = num.length k>3; k++)
{
        Num[k]=num[k++]
}
    Num[3] = 35;

```

Answer: 
You need to

1. allocate a new array with room for one new element.

```
int[] newArray = new int[oldArray.length + 1];

```
2. Copy over all elements and leave room for the one to insert.

```
for (int i = 0; i < newArray.length - 1; i++)
    newArray[i < insertIndex ? i : i + 1] = oldArray[i];

```
3. Insert 35 in the empty spot.

```
newArray[insertIndex] = numberToInsert;

```

---

Note that it's **not** possible to do in a method like this:

```
public static void method(int[] num, int index, int addnum)
              ^^^^

```

since you **can't** change the length of `num`.

You *need* to allocate a new array, which means that need to *return* the new array:

```
public static int[] method(int[] num, int index, int addnum)
              ^^^^^

```

and then call the method like this:

```
myArr = method(myArr, 3, 35);

```
Well, you can't unless there is "extra space" in your array, and then you can shift all elements [starting from `index`] one element to the right, and add 35 [`num`] to the relevant place.

[what actually happen is that the last element is discarded out].

However - a better solution will probably be to use an [ArrayList](http://docs.oracle.com/javase/1.4.2/docs/api/java/util/ArrayList.html), and use the method [`myArrayList.add(index,element)`](http://docs.oracle.com/javase/1.4.2/docs/api/java/util/ArrayList.html#add%28int,%20java.lang.Object%29)