InputFromKeyBoard

This commit is contained in:
2021-04-26 10:14:49 +05:30
parent 5389de5ec9
commit 72b646f1ff
2 changed files with 25 additions and 1 deletions

22
InputFromKeyBoard.java Normal file
View File

@@ -0,0 +1,22 @@
// Program to demonstrate input from keyboard using Command line argument.
import java.util.Scanner;
public class InputFromKeyBoard {
public static void main(String [] args) {
int n;
Scanner sc = new Scanner(System.in);
System.out.print("Enter the number of names you want to store: ");
n=sc.nextInt();
String[] array = new String[n];
System.out.println("Enter the names: ");
for(int i=0; i<n; i++) {
array[i]=sc.next();
}
System.out.println("The names are: ");
for (String s : array) {
System.out.println(s);
}
}
}