Reputation: 581
When we make our simple java class we have to write the below line
public static void main(String []args)
It could be also written as ..
public static void main(String args[] )
public static void main(String... a )
What are the other possible solutions that we can write above statement in a different way..!
Upvotes: 0
Views: 48
Reputation: 718718
You could declare args
as final
, or use a different name for the parameter.
You could add a throws
clause (thanks Prince), though it would be better to catch and diagnose any exceptions yourself. (Think of what your users are going to make of random stacktraces ...)
You could declare the main
method as synchronized
or (possibly) final
, but both of those are pointless in any realistic scenario.
And of course, you can specify the modifiers in a different order. That is both pointless and (IMO) annoying.
is there any difference in terms of interchanging them?
None whatsoever. It just makes your code harder to read ... because you are not following accepted Java code style conventions.
Upvotes: 1