0
public class Mayank {

public static void main(String ...aa){
  System.out.println("Yes it is working");
       }
}

Is there any decrease in efficiency of program,if we use this syntax.

Innovation
  • 1,514
  • 17
  • 32

4 Answers4

5

It's not showing you a compilation error, because although the formatting is all over the place, the code is syntactically correct.

BTW The String... is an ellipsis which is like a String[] and is fine to use. (I prefer it)

I would get your IDE to format it like this

public class Mayank {
    public static void main(String... ignored) {
        System.out.println("Yes it is working");
    }
}
Bathsheba
  • 231,907
  • 34
  • 361
  • 483
Peter Lawrey
  • 525,659
  • 79
  • 751
  • 1,130
1

because there is nothing wrong with the code.

You can refer to this Q&A to get a clear view. public static void main(String arg[ ] ) in java is it fixed?

Community
  • 1
  • 1
palayan
  • 59
  • 6
1

main method in java accepts String array arguments so all the following are valid types

public static void main(String ...aa){


public static void main(String[] aa){


public static void main(String []aa){


public static void main(String aa[]){

public static void main(String [] aa){

As per your updated post varargs means variable arguments.If you are not sure how many arguements you want to pass then you can use varargs.

Note that varargs only support java 5 onwards.So if you are using java version older than 5 then this will definitely show you error

SpringLearner
  • 13,738
  • 20
  • 78
  • 116
0

main(String... args) can just run in jdk1.5+,and main(String[] args) can run in each version.and is there 's any difference as u never call the method directly?

Grumpy
  • 1