command line arguments in java

  • Thread starter Thread starter GeX
  • Start date Start date

GeX

GeX

Soldato
Joined
17 Dec 2002
Posts
6,981
Location
Manchester
i'm a bit rusty with java, what i want to do is from the CLI, launch the app and using an argument (add/remove) add two strings into an array.

i've not given any thought to the array side of things as i know what im doing there, what im not sure is how to handle the arguments.

Code:
public class Echo {
    public static void main (String[] args) {
        for (String s: args) {
            System.out.println(s);
        }
    }
}

i know that that will echo any arg i pass it, but if i say gave it "echo hello you smell", it would treat each arg as a new string, and echo it on a new line. What i don't know is how to take each string and copy it into a string within my code.

Am i making sense here?
 
Back
Top Bottom