Results 1 to 3 of 3
Thread: Why doesn't main use varagrs?
- 01-19-2010, 03:25 PM #1gcampton Guest
Why doesn't main use varagrs?
I was curious as to why the default main does not use varargs. Unlike other languages and scripting languages the first position of arguments (the zeroth element) does not reference the program name/package/jar
So I really I would think it would have been better to implement main in the format of:
The above code compiles and runs naturally, I guess the question is kind of pointless as varargs and an array are pretty much the same thing. But it seems a bit funny to me why have an array as convention when varargs is more suited for situations where you don't know if there will be zero, 1 or multiple args.Java Code:public class foo { public static void main(String... args) { // TODO stuff with args if they exist.... } }Last edited by gcampton; 01-19-2010 at 03:27 PM.
-
So, ask yourself a question: when were varargs introduced into Java? In the beginning?
Hint: look here
- 01-19-2010, 03:44 PM #3gcampton Guest
Similar Threads
-
Exception in thread "main" java.lang.NullPointerException at LinkedList.main(Link
By kavitha_0821 in forum New To JavaReplies: 6Last Post: 07-16-2009, 03:30 PM -
Exception in thread "main" java.lang.NullPointerException at LinkedList.main(Link
By kavitha_0821 in forum New To JavaReplies: 1Last Post: 07-16-2009, 10:35 AM -
[SOLVED] Why main() in java is declared as public static void main?
By piyu.sha in forum New To JavaReplies: 5Last Post: 10-06-2008, 12:11 AM -
ERROR: Exception in thread "main" java.lang.NoSuchMethodError: main
By barney in forum New To JavaReplies: 1Last Post: 08-07-2007, 07:10 AM -
exception in thred main java.lang.nosuchmethoderror: main
By fernando in forum Java AppletsReplies: 1Last Post: 08-06-2007, 09:11 AM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks