0

import java.util.Scanner; public class Program { public static void main(String[] args) { int[] arr=new int[5]; for(int i=0;i<5;i++) { Scanner ch=new Scanner(System.in); arr[i]=ch.nextInt(); System.out.println(arr[i]); } }}

I want to know the error in this code

29th Jun 2016, 5:07 PM
Mayank Garg
Mayank Garg - avatar
2 odpowiedzi
+ 3
put the scanner object created to outside of the loop.
30th Jun 2016, 9:23 AM
Madhvendra Singh Singh
Madhvendra Singh Singh - avatar
0
Thank you dude
12th Jul 2016, 8:23 AM
Mayank Garg
Mayank Garg - avatar