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.
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.
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");
}
}
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?
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
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?