Thinking in Java Fourth Edition Bruce Eckel Chapter 4 Exercise 20

Exercise 20: Create a main( ) that uses varargs instead of the ordinary main( ) syntax. Print all the elements in the resulting args array. Test it with various numbers of command-line arguments.

public class VarargEx20
    public static void main(String... args)
        for(String s : args)
            System.out.print(s + " ");


Leave a Reply

Your email address will not be published. Required fields are marked *