In C/C++ we have memset() function which can fulfill my wish but in Java how can i initialize all the elements to a specific value? Wh
Using Java 8, you can simply use ncopies of Collections class:
Object[] arrays = Collections.nCopies(size, object).stream().toArray();
In your case it will be:
Integer[] arrays = Collections.nCopies(10, Integer.valueOf(1)).stream().toArray(Integer[]::new);
.
Here is a detailed answer of a similar case of yours.