Search Results

Search found 1 results on 1 pages for 'lightk3ira'.

Page 1/1 | 1 

  • java shift elements in array

    - by Lightk3ira
    Hey I am trying to shift elements forward sending the last element in the array to data[0]. I did the opposite direction but I can't seem to find my mistake in going in this direction. Pos is users inputed shift times amount temp is the temporary holder. data is the array if(pos 0) { do { temp = data[data.length -1]; for(int i =0; i < data.length; i++) { if(i == data.length-1) { data[0] = temp; } else { data[i+1] = data[i]; } } pos--; }while(pos > 0); } Thanks.

    Read the article

1