- 1
how to input array using scanner
4 odpowiedzi
+ 4
Use for loop and write input statement in loop body
import java.util.Scanner;
class MyClass {
    public static void main(String[ ] args) {
        Scanner myVar = new Scanner(System.in);
       for(int i=1;i<5;i++)
       
        System.out.println(myVar.nextLine());        
    }
}
+ 3
ArrayList<Integer> obj = new ArrayList<>();
      
      Scanner sc = new Scanner(System.in);
      
        while(sc.hasNextInt())
        {
            obj.add(sc.nextInt());
        }
+ 1
U can use a loop.
0
Ya



