diff --git a/client/src/pages/guide/english/java/methods/index.md b/client/src/pages/guide/english/java/methods/index.md index bd7a15dad7..802b3aec9e 100644 --- a/client/src/pages/guide/english/java/methods/index.md +++ b/client/src/pages/guide/english/java/methods/index.md @@ -48,6 +48,28 @@ public class Car { } } ``` +If we not sure with the distinct number of parameters passed in a method then use 'Variable Arguments (Varargs) Method' + +Initialize parameter with three dots and will have same dataType. +Passed arguments will store in an array and also accessible as array +```java +public class Main +{ + public static void main(String[] args) { + + Main p=new Main(); + + System.out.println(p.sum(5,5,5,5,5,5,5,5,5)); //can pass any number of argument. + } + +int sum(int ...a) //decleration of variable argument method. + {int sum=0; + for(int i=0;i