0% found this document useful (0 votes)
5 views1 page

Java Program to Input and Display Array

The document is a Java program that creates an array of 5 integers and takes user input to populate this array. It then prints the entered numbers to the console. The program utilizes a Scanner object for input and employs loops for both input collection and output display.

Uploaded by

Huzeefa Pathan
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views1 page

Java Program to Input and Display Array

The document is a Java program that creates an array of 5 integers and takes user input to populate this array. It then prints the entered numbers to the console. The program utilizes a Scanner object for input and employs loops for both input collection and output display.

Uploaded by

Huzeefa Pathan
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

import [Link].

Scanner;

public class Arr {


public static void main(String[] args) {
// Create an array of 5 elements
int[] numbers = new int[5];

// Create a Scanner object to take input from the user


Scanner scanner = new Scanner([Link]);

// Take 5 inputs from the user


[Link]("Enter 5 numbers:");
for (int i = 0; i < 5; i++) {
numbers[i] = [Link](); // Storing input in array
}

// Print the elements using a for loop


[Link]("The entered numbers are:");
for (int i = 0; i < 5; i++) {
// Printing each element of the array
[Link](numbers[i]);
}
}
}

You might also like