Q) Initialize an array with input values from the user
Example:
Enter 10 elements of the array:
1 2 3 4 5 6 7 8 9 10
import java.util.Scanner; public class ArrayInputSample { public void enterArray () { Scanner sc= new Scanner (System.in); int [] sampleArray= new int[10]; //declaration, creation, and assignment of array reference to a array variable for (int i=0; i<sampleArray.length; i++){ sampleArray[i]= sc.nextInt(); // initialiing each element of the array } } }