Reputation: 3
The error that i am getting is of '.class' expected. All i want to do is to get the values of the array from the user. Kindly help me out.
int[] array = new int [10];
Scanner input=new Scanner (System.in);
// The error comes from the next line.
int array = input.nextInt[];
System.out.println("1. Find Mean");
System.out.println("2. Change Number");
System.out.println("1. Print All");
System.out.println("1. Exit");
Upvotes: 0
Views: 37
Reputation: 201447
You already have a variable named array
.
int[] array = new int [10]; // <-- right there.
int count = 0; // <-- add this.
Scanner input=new Scanner (System.in);
array[count++] = input.nextInt(); // <-- parens for a method call,
// square brackets for the array, and add one to the count.
Upvotes: 2
Reputation: 178263
Use parentheses ()
for a method call with no parameters, not brackets []
.
int array = input.nextInt();
Upvotes: 1