Fill boolean, byte, char,short, int, long, float array


import java.util.Arrays;

public class Main {
  public static void main(String[] argv) throws Exception {
    int startIndex = 0;
    int endIndex = 4;

    boolean[] booleanArr = new boolean[10];
    boolean booleanFillValue = true;

    Arrays.fill(booleanArr, startIndex, endIndex, booleanFillValue);

    byte[] byteArr = new byte[10];
    byte byteFillValue = 1;

    Arrays.fill(byteArr, startIndex, endIndex, byteFillValue);

    char[] charArr = new char[10];
    char charFillValue = 1;

    Arrays.fill(charArr, startIndex, endIndex, charFillValue);

    short[] shortArr = new short[10];
    short shortFillValue = 1;

    Arrays.fill(shortArr, startIndex, endIndex, shortFillValue);

    int[] intArr = new int[10];
    int intFillValue = 1;

    Arrays.fill(intArr, startIndex, endIndex, intFillValue);

    long[] longArr = new long[10];
    long longFillValue = 1;

    Arrays.fill(longArr, startIndex, endIndex, longFillValue);

    float[] floatArr = new float[10];
    float floatFillValue = 1;

    Arrays.fill(floatArr, startIndex, endIndex, floatFillValue);
  }
}
Home 
  Java Book 
    Runnable examples  

Data Type Array:
  1. Append item to array
  2. Append an object to an array.
  3. Append one array to another
  4. Clone Array
  5. Clones two dimensional float array
  6. Compare two arrays by reference
  7. Compare Two byte Arrays
  8. Compare Two boolean Arrays
  9. Compare Two char Arrays
  10. Compare Two double Arrays
  11. Compare Two float Arrays
  12. Compare Two int Arrays
  13. Compare Two long Arrays
  14. Compare two object arrays
  15. Compare Two short Arrays
  16. Compare two two-dimensional array
  17. Concatenate arrays
  18. Convert array to set
  19. Convert string array to string
  20. Convert string array to List
  21. Convert multi-dimensional array to string
  22. Convert an array to a Map
  23. Copy array
  24. Copy Elements from One Array to Another
  25. Copy and add an array at the end of the new array
  26. Extend an array with additional extra space
  27. Extend to Double the size of an array
  28. Fill boolean, byte, char,short, int, long, float array
  29. Get array upperbound
  30. Get the number of dimensions
  31. Insert an Element into a Sorted Array
  32. Insert the specified element at the specified position in the array
  33. Insert source array in the target array at offset
  34. Maximum value in an array
  35. Minimum value in an array.
  36. Merge two arrays
  37. Remove duplicate element from array
  38. Remove the element at the specified position from the specified array.
  39. Reverses the order of an array(byte, long, int)
  40. Search an element in an array and return the index and last index
  41. Binary Search on an Array
  42. Shift all elements right by one
  43. Shift all elements left by one
  44. Shuffle an array
  45. Sort byte(char,double, float, int) Array
  46. Sort char array
  47. Sort int Array
  48. Sort long Array
  49. Sort short Array
  50. Sort string type array in case insensitive order and case sensitive order
  51. Sort an Array in Descending (Reverse) Order
  52. Start with one array
  53. Subarray from array that starts at offset