Java Methods with Variable Number of Arguments
In this tutorial, you will learn how to create methods which takes variable number of arguments in java programming.
You will learn how to create methods which takes variable number of arguments, what is their advantage in detail with example.
Source code for this video tutorial
package methods; public class Tutorial { public static void main(String[] args) { display("anil",22.36); } public static void display(String name, double avg, int...numbers){ System.out.println(name); System.out.println(avg); if(numbers.length == 0){ System.out.println("No parameters"); }else{ for(int num:numbers){ System.out.println(num); } } } }