+ 1

What is the problem in this code?

I want to get user input for arry length and its values! https://code.sololearn.com/cjVWHI5Bj2jU/?ref=app

24th Jun 2018, 9:38 AM
Jamil Mansoura
Jamil Mansoura - avatar
3 Answers
+ 5
import java.util.Scanner; public class Program { public static void main(String[] args) { Scanner x= new Scanner(System.in); int y = x.nextInt(); System.out.println(y); int[ ] primes = new int [y] ; for (int n = 0; n< primes.length;n++) { int z = x.nextInt(); primes[n] = z; System.out.println(z); } for (int t: primes) { System.out.println(t); } } }
24th Jun 2018, 10:03 AM
Dev
Dev - avatar
+ 1
x is a scanner object. you have to make another variable to save the user input.
24th Jun 2018, 9:42 AM
Disvolviĝo;
Disvolviĝo; - avatar
0
Please, can you show me how? Programanta ludanto
24th Jun 2018, 9:48 AM
Jamil Mansoura
Jamil Mansoura - avatar