If you want to fill an array with default values in Java , you can use the Arrays.fill method to do it . The Arrays.fill method lets the developers fill the empty array with the default values.
How to fill an array with default values in Java ?
Below is an example of the usage of the Arrays.fill method in java .
package com.abundantcode; import java.util.Arrays; public class Main { public static void main(String[] args) { String[] input = new String[5]; Arrays.fill(input,"Abundantcode.com's Java Lab programs"); for(String item:input) System.out.println(item); } }
Leave a Reply