Variable Length Arguments -
The cal method has a parameter "a" that is an integer.
But the trick is "..." three dots, meaning that a is actually an integer array with unknown size. Btw, I can send 5 parameters, 10 ,400 ,500 , it doesnt matter.
public class shama {
public static void main(String[] args) {
cal(15,24,32,1,2,5,3,242,52);
}
public static void cal (int...a)
{
for(int x:a)
System.out.println("vals: " + x);
}
}
Result ;
run:
vals: 15
vals: 24
vals: 32
vals: 1
vals: 2
vals: 5
vals: 3
vals: 242
vals: 52