Need Of Variable Length Arguments in Java Part 1: Varargs

Hi, this video covers variable length argument in java.We are going to discover the reason why we need vararg in java.We will start this concept creating a real-time scenario and understanding the problem then we get into the coding.

variable argument lists in java //

Java var-args can be written inside a method argument which can accept a group of elements.This helps us in situations like when we are not sure how many arguments, we should take in a method.

If we take variable length argument as the argument inside a method then the method can handle any number of arguments passed into it.

So we can think, var-args in java is just similar to a one-dimensional array but the basic differences taking an array as a parameter and a var-args as a parameter is :

if we need to pass a method which accepts an array as an argument, then we have to pass an array object inside the method argument while calling the method.( this is the only way to call an array args type method)

we can’t pass elements directly to a method which takes an array as an argument.

But if we use a method which takes, var-args as an argument, then the advantages that we will get is :

we can pass an array object to this method and also we can pass a bunch of elements directly to this method to execute it.

please follow this tutorial for example.

Java interview question on hashcode() and equals() || Java collection interview questions on HASHMAP

https://youtu.be/Nr56SlbMed4

Why String is immutable in Java ? || The four reason you must know

https://www.youtube.com/playlist?list=PL3NrzZBjk6m_-kS_ZNB9gl87QJipwZFuF

Hashmap Internal working

https://www.youtube.com/playlist?list=PL3NrzZBjk6m9do1opOKwx_C7d2HRJzpwG

Why we need constructor inside an abstract class ? || Popular Java interview question

https://youtu.be/jmxOsCGV120

Stay tuned and like my Facebook page for more.

https://www.facebook.com/seleniumexpress/

Music :

credits : -
(intro)
1)
Adventures by A Himitsu https://soundcloud.com/a-himitsu
Creative Commons — Attribution 3.0 Unported— CC BY 3.0
http://creativecommons.org/licenses/b
Music released by Argofox https://youtu.be/8BXNwnxaVQE
Music provided by Audio Library https://youtu.be/MkNeIUgNPQ8

NCM Epic Music Ender Guney
https://www.youtube.com/c/NCMEpicMusic


intro template :
www.youtube.com/Alexbau01

#java #varargs

Need Of Variable Length Arguments in Java Part 1: Varargs