60 371
Assignments Done
98,1%
Successfully Done
In April 2018

Answer to Question #9921 in Java | JSP | JSF for Kay-Z

Question #9921
How do I make a user enter values into an array?
Expert's answer
import java.util.Scanner;

public class Test {
public static void
main(String[] args) {
Scanner in = new Scanner(System.in);

System.out.println("Please enter the size of an array: ");
int size =
in.nextInt();
int [] array = new int[size];
for (int i =
0; i < size; i++) {
System.out.println("Please enter element #" +
i + ": ");
array[i] = in.nextInt();
}

System.out.println("Here is your array: ");
for (int i = 0; i <
size; i++)
System.out.print(array[i] + " ");
}
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be first!

Leave a comment

Ask Your question

Submit
Privacy policy Terms and Conditions