Skip to content

Instantly share code, notes, and snippets.

@RashidJorvee
Last active January 5, 2019 15:18
Show Gist options
  • Select an option

  • Save RashidJorvee/d8441fbecca71b72175b9b193b96cd51 to your computer and use it in GitHub Desktop.

Select an option

Save RashidJorvee/d8441fbecca71b72175b9b193b96cd51 to your computer and use it in GitHub Desktop.
Method which accept n number of parameters in Java
package rashid.jorvee;
import java.util.Map;
/*
* Method which accept n number of parameters.
*/
public class MethodWithNParameters {
public static void main(String[] args) {
String name="Rashid";
String city="New Delhi";
String country="India";
MethodWithNParameters oby=new MethodWithNParameters();
oby.acceptAnyNumberOfArguments(name, city, country);
}
private void acceptAnyNumberOfArguments(String ...args) {
for(String display:args){
System.out.println(display);
}
}
}
@RashidJorvee

Copy link
Copy Markdown
Author

Output:

Rashid 
New Delhi 
India 

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment