Last active
January 5, 2019 15:18
-
-
Save RashidJorvee/d8441fbecca71b72175b9b193b96cd51 to your computer and use it in GitHub Desktop.
Method which accept n number of parameters in Java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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); | |
| } | |
| } | |
| } |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Output: