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
Why String is immutable in Java ? || The four reason you must know
Hashmap Internal working
Why we need constructor inside an abstract class ? || Popular Java interview question
Stay tuned and like my Facebook page for more.
credits : -
Adventures by A Himitsu https://soundcloud.com/a-himitsu
Creative Commons — Attribution 3.0 Unported— CC BY 3.0
Music released by Argofox https://youtu.be/8BXNwnxaVQE
Music provided by Audio Library https://youtu.be/MkNeIUgNPQ8
NCM Epic Music Ender Guney
intro template :