Variable argument or varargs in Java allows you to write more flexible methods which can accept as many argument as you need. variable arguments or varargs were added in Java 1.5 along with great language features like Java Enum, Generics, auto boxing and various others. Variable arguments a relatively small feature but useful for a developer who has been well aware about method and array. Some time we have a scenario that one method can take variable number of argument and now with varargs from language makes it much easier. In this Java tutorial we will see How variable arguments makes it easy to write convenient method which can accept any number of arguments, perfect candidates are sum() and average() kind of methods.
This article is in continuation of exploring features of Java programming language. I have already covered fork-join framework from Java 7 and automatic resource management or ARM blocks, if you haven't read them already you may find them useful.
This article is in continuation of exploring features of Java programming language. I have already covered fork-join framework from Java 7 and automatic resource management or ARM blocks, if you haven't read them already you may find them useful.