Java Var args Method - Syntax and Declaration (Part - 2)

preview_player
Показать описание
In this tutorial we’re going to look at Syntax & Declaration of Var-args Method in Java programming language in detail and how to declare and define a Var args method and how to call var args methods in Java as well as explain the role of Ellipsis(…) three dots in it with simple program .

You may ask why we need it. Where it is useful?

Let me explain you first, Problem until Java 4.0.

1. We cannot declare a method with variable number of arguments.
2. If there is a change in a number of arguments then compulsory we should declare a new method, which increases the length of code and reduces readability.

So, to overcome this problem “SUN” people introduced var-args method concept in Java 5.0 or jdk1.5 version that are explained it with programs.

In my next tutorial, I will discuss about Var args method some internal details and how to access values from var args parameter.

#java #Varargs #VariableLength #OCJP #Programming #Tutorials #Vararg

Social Links: Don't hesitate to contact me if you have any further questions.

Рекомендации по теме
Комментарии
Автор

Now, role of ellipsis or three dots(...) concept in java is clearly understand. Thank you VK Programming Villa :)

inceptiontech
Автор

Three dots are changed total concept of method overloading. It increase readability as well as less code to write. Thanx for sharing. Keep it up.

remotepc