Command line to array


How do i take a command line input and place it in an array?

This has been driving me nuts for two days.

please please please help :confused:

which prog language r u using to do this ?

Hi, im using Java.

Ive just figured out that commandline input is stored in the args .

Does anyone know a simple clean way to display the contents of the args???

for(String s1:args)

put it in ur main()

got it?

I only have the one? Im pretty sure im making a mess of it ?

What do you think? Ive been using Java for three days…any advice?

import java.util.Scanner;
public class AddStudent {

 * @param args the command line arguments
public static void main(String args[])

//for(String s1:args)
Scanner newStudent = new Scanner (;

System.out.println("Please enter student name:"); //prompt for input
String studentName = newStudent.nextLine(); // read line of input
System.out.println(); //displays blank line
System.out.println( studentName);//displays student name
System.out.printf("has been successfully enrolled! \

");//states string


public static void main(String args)
Scanner newStudent = new Scanner (;
System.out.println(“enter first string”);
String s1=new String[10];
System.out.println("first string is : “+s1[0]+”
System.out.println(“enter second string”);
System.out.println("second string is : "+s1[1]);

thanks for that thats great!!


Rather than second string equals +s1

how do i get

system.out.println(s1 All array entries)