Write a Java Program to input and print n elements in an array

By | January 25, 2017

Write a Java  Program to input and print n elements in an array 


  • Write a Java program to read elements in an array and print array. How to input and display elements in an array using for loop in java programming.

Array uses an index based mechanism for fast and easy accessing of elements. Array index starts from 0 to N – 1 (where N is the total number of elements in the array).
Example:
Input size: 5
Input elements: 1
2
3
4
5

Output: 1, 2, 3, 4, 5

Let’s demonstrate this through a program……


SOURCE CODE ::

 

 

OUTPUT ::

 

 

Leave a Reply