Here we've added an UnflaggedOption to greet specific names. It's marked as "greedy", so any number of names on the command line are associated with this option.

    public static void main(String[] args) throws Exception {
        JSAP jsap = new JSAP();

        FlaggedOption opt1 = new FlaggedOption("count")


        Switch sw1 = new Switch("verbose")


        // Create an unflagged option called "names" that we'll use to
        // say hello to particular people.
        // To make it more interesting, we'll make it "greedy", so
        // it consumes all remaining unflagged tokens on the command line
        // as multiple values
        UnflaggedOption opt2 = new UnflaggedOption("name")


        JSAPResult config = jsap.parse(args);

        String[] names = config.getStringArray("name");
        for (int i = 0; i < config.getInt("count"); ++i) {
            for (int j = 0; j < names.length; ++j) {
                    (config.getBoolean("verbose") ? "Hello" : "Hi")
                        + ", "
                        + names[j]
                        + "!");
[mlamb@morbo]$ java com.martiansoftware.jsap.examples.Manual_HelloWorld_4 -n 2 --verbose Bender Fry Leela
Hello, Bender!
Hello, Fry!
Hello, Leela!
Hello, Bender!
Hello, Fry!
Hello, Leela!

[mlamb@morbo]$ java com.martiansoftware.jsap.examples.Manual_HelloWorld_4 Kif -n 3
Hi, Kif!
Hi, Kif!
Hi, Kif!

[mlamb@morbo]$ java com.martiansoftware.jsap.examples.Manual_HelloWorld_4 -v -n 2
Hello, World!
Hello, World!