Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVA

array input java

int n;  
Scanner sc=new Scanner(System.in);  
System.out.print("Enter the number of elements you want to store: ");  
//reading the number of elements from the that we want to enter  
n=sc.nextInt();  
//creates an array in the memory of length 10  
int[] array = new int[10];  
System.out.println("Enter the elements of the array: ");  
for(int i=0; i<n; i++)  
{  
//reading array elements from the user   
array[i]=sc.nextInt();  
}  
Source by www.javatpoint.com #
 
PREVIOUS NEXT
Tagged: #array #input #java
ADD COMMENT
Topic
Name
2+2 =