Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
int [] arr = new int[17];
Arrays.fill (arr, 8);
Arrays.fill (arr, 5, 12, 7);
/**
* Assigns the specified Object reference to each element of the specified
* range of the specified array of Objects. The range to be filled
* extends from index <tt>fromIndex</tt>, inclusive, to index
* <tt>toIndex</tt>, exclusive. (If <tt>fromIndex==toIndex</tt>, the
* range to be filled is empty.)
*
* @param a the array to be filled.
* @param fromIndex the index of the first element (inclusive) to be
* filled with the specified value.
* @param toIndex the index of the last element (exclusive) to be
* filled with the specified value.
* @param val the value to be stored in all elements of the array.
* @throws IllegalArgumentException if <tt>fromIndex > toIndex</tt>
* @throws ArrayIndexOutOfBoundsException if <tt>fromIndex < 0</tt> or
* <tt>toIndex > a.length</tt>
*/
public static void fill(Object[] a, int fromIndex, int toIndex,Object val){
rangeCheck(a.length, fromIndex, toIndex);
for (int i=fromIndex; i<toIndex; i++)
a[i] = val;
}
public static void fill (Object[] a, int fromIndex, int toIndex, int val)
{
rangeCheck(a.length, fromIndex, toIndex);
for (int i=fromIndex; i<toIndex; i++)
a[i] = val;
}