This Java program prompts the user to input the size of an array, takes input values from the user, and then prints out the values of the array. Here's a brief explanation of what the program does:
import java.util.Scanner; class Array_Size { public static void main(String[] args) { Scanner input =new Scanner(System.in); System.out.print("Enter the Array Limit :"); int l =input.nextInt(); int [] a =new int[l]; for(int i=0;i<l;i++) { System.out.printf("Element of a[%d] :",i); a[i]=input.nextInt(); } System.out.println("\nDisplay Array Elements...\n"); for(int e:a) { System.out.println(e); } } }
Enter the Array Limit :4 Element of a[0] :10 Element of a[1] :20 Element of a[2] :30 Element of a[3] :40 Display Array Elements... 10 20 30 40
Learn All in Tamil © Designed & Developed By Tutor Joes | Privacy Policy | Terms & Conditions