Results 1 to 5 of 5
Thread: String[] arg and String... args
- 04-28-2009, 03:01 PM #1
Member
- Join Date
- Jan 2009
- Posts
- 14
- Rep Power
- 0
String[] arg and String... args
Hi All,
As in Java 1.5 and lateral we can use String... arg instead of String [] args in
public static void main() method.
so it means if we can use both of them as a interchangebly.
is this true? if yes the what would be the answer of below question?
logIt(”log message 1 “);
logIt(”log message2”,”log message3”);
logIt(”log message4”, “log message5”, “log message6);
Which declaration satisfies this requirement?
A. public void logIt(String * msgs)
B. public void logIt(String [] msgs)
C. public void logIt(String... msgs)
D. public void logIt(String msg1, String msg2, String msg3)
Answer: ??
Regards,
Mahendra Athneria
Mumbai
India
- 04-28-2009, 03:18 PM #2
Senior Member
- Join Date
- Aug 2008
- Posts
- 384
- Rep Power
- 5
C, obviously. You should know why - if you get this question. If you don't, post. :)
I die a little on the inside...
Every time I get shot.
- 04-28-2009, 03:51 PM #3
varargs ... a creature out of a Tolkein book?
Doing some searching, I found the following information...
Passing Information to a Method or a Constructor (see "Arbitrary Number of Arguments" section)
Java Varargs
Java Tips - Using the VarArgs Language Feature
So the name of this beast (Object... arguments) is called "varargs".
Luck,
CJSLChris S.
Difficult? This is Mission Impossible, not Mission Difficult. Difficult should be easy.
- 04-28-2009, 05:09 PM #4
Member
- Join Date
- Jan 2009
- Posts
- 14
- Rep Power
- 0
Thanks Chris for your Answer. :)
Regards,
Mahendra
- 04-28-2009, 07:20 PM #5
Similar Threads
-
Why can't we write main without String args[]
By shailender in forum New To JavaReplies: 6Last Post: 06-17-2013, 09:28 AM -
combine string[] into string like perl's join function
By tekberg in forum Advanced JavaReplies: 9Last Post: 02-23-2009, 01:05 PM -
Error: LengthCharAt.java:3: ';' expected public static void main (String[] args)
By antgaudi in forum New To JavaReplies: 9Last Post: 11-22-2008, 11:03 PM -
[SOLVED] ReadLine(String fmt,Object... args) of Console class
By Pooja Deshpande in forum New To JavaReplies: 4Last Post: 04-25-2008, 05:51 AM -
Using java.util.Scanner to search for a String in a String
By Java Tip in forum Java TipReplies: 0Last Post: 11-20-2007, 04:59 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks