Check out example codes for "how do i scan for n times in java". It will help you in understanding the concepts better.

Code Example 1

//Link: https://www.quora.com/How-do-I-can-get-n-lines-of-text-as-input-from-the-user-in-java

//using Scanner

import java.util.Scanner; 
public class ScannerDemo 
{ 
  public static void main(String args[]) 
  { 
     Scanner sc = new Scanner(System.in); 
     int n; 
     n=Integer.parseInt(sc.nextLine()); 
    for(int i=1; i<=n; i++) 
    {   
     System.out.print("Enter input:"); 
     String input = sc.nextLine(); 
     System.out.println(input); 
    } 
  } 
}

Learn ReactJs, React Native from akashmittal.com