Untitled

mail@pastecode.io avatar
unknown
plain_text
2 years ago
804 B
3
Indexable
Never
import java.util.Scanner;
/**
 *
 * @author win
 */
public class Main {
    
     public static void inputString() {     
    Scanner sc = new Scanner(System.in);  
    System.out.print("Please enter the number of strings you want to enter: ");   
        //takes an integer input         
        String[] string = new String [sc.nextInt()];      
    
    //consuming the <enter> from input above  
    sc.nextLine();   
    for (int i = 0; i < string.length; i++){  
        string[i] = sc.nextLine();  
        }  
    System.out.println("\nYou have entered: ");  
    
   //for-each loop to print the string  
    for(String str: string){  
        System.out.println(str);  
        }  
     }  
    public static void main(String[] args){
        inputString();
    }
}