Answers for "scan string in java for n times"

1

how do i scan for n times in java

//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); 
    } 
  } 
}
Posted by: Guest on August-01-2020

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language