+ 1

Where is The Error.." Exampleprg(String... person) { " is that line not valid.

class Exampleprg { Exampleprg(String... person) { for (String name : person) { System.out.println("Hellow Mr. " + name); } } } public class VarArgs { public static void main( String args[]) { Exampleprg("Ayush","Sammy","Singh","Kumar"); } } // Output: // Hellow Mr. First Args. // Hellow Mr. Second Args. // Hellow Mr. nth Args.

13th Jun 2020, 3:45 AM
Ayush Singh
Ayush Singh - avatar
1 Answer
0
you need create an object, by 'new' command // Exampleprg("Ayush","Sammy","Singh","Kumar"); new Exampleprg("Ayush","Sammy","Singh","Kumar");
13th Jun 2020, 10:28 AM
zemiak