java - How to add or remove a value on an array? -


1st quesiton :

how remove array ? parameter specify index removed. have update in new array , return it.

int[] removefromarray(int[] array, int index) {     int[] newarray = array } 

2nd quesiton:

i guess same concept, have add array.

conditions: cant use arrayutils , etc.

i'm guessing can done using for loops ?

cheers

if want remove element array , can following

static int[] removefromarray(int[] s, int idx) {     int[] dest = new int[s.length-1];     system.arraycopy(s, 0, dest, 0, idx);     system.arraycopy(s, idx+1, dest, idx, s.length-idx-1);           return dest; } 

i suggest consider other options 'arraylist' or suggestions made thihara.


Comments

Popular posts from this blog

.htaccess - First slash is removed after domain when entering a webpage in the browser -

Automatically create pages in phpfox -

c# - Farseer ContactListener is not working -