Search Results

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

Page 1/1 | 1 

  • Creating a New Reverse Java Array

    - by mandir08
    Given an array of ints length 3, return a new array with the elements in reverse order, so {1, 2, 3} becomes {3, 2, 1}. public int[] reverse3(int[] nums) { int[] values = new int[3]; for(int i=0; i<=nums.length-1; i++) { for(int j=nums.length-1; j>=0; j--) { values[i]=nums[j]; } } return values; } I cant get this to work properly, usually the last int in the array, becomes every single int in the new array

    Read the article

1