Java Array Fill fillArrayWithHalfSorted(int[] nums)

Here you can find the source of fillArrayWithHalfSorted(int[] nums)

Description

fill Array With Half Sorted

License

Open Source License

Declaration

public static void fillArrayWithHalfSorted(int[] nums) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

public class Main {
    public static void fillArrayWithHalfSorted(int[] nums) {

        // first part is sorted
        for (int i = 0; i < nums.length / 2; i++)
            nums[i] = i;/*from  w ww  . j  a v a2s . co  m*/

        // reverse ordered from middle
        int start = nums.length;
        for (int i = nums.length / 2; i < nums.length; i++)
            nums[i] = start--;
    }
}

Related

  1. fillArray(String[] array, int size, String fillString)
  2. fillArray(T[] arr, T val)
  3. fillArray2D(double[][] arr, double value)
  4. fillArrayWith(byte[] dest, byte[] pattern)
  5. fillArrayWithByte(byte[] array, byte value)
  6. fillColor(int[][] dist)
  7. filledIntArray(int length, int cont)