O'Reilly logo

Java Garage by Eben Hewitt

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Methods Allow Variable-Length Parameter Lists

Varargs. Yes, that is what passes for a word these days (did you ever read Ray Bradbury's “The Sound of Thunder”?). The vararg is a thing that they have in C# and other languages and it means that you stomp your foot and say, “This method has a bunch of parameters and I just don't know how many parameters a client might want to pass it, all right?” It means “variable length argument list.”

This is an easy concept to start working with. The following class defines a method that accepts a vararg, and invokes the same method passing it first several arguments and then fewer arguments. The arguments come in as an array.

 package net.javagarage.varargs; /* Demos how to use variable length argument lists. ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required