Results 1 to 3 of 3
- 05-09-2010, 12:16 AM #1
Member
- Join Date
- May 2010
- Location
- Colorado
- Posts
- 6
- Rep Power
- 0
the strange and weird world of Varargs...
guess the printout after each call to the "print" method...
public class TestingVarargs {
static void print(Object...obj){
System.out.println("Object...: " + obj[0]+ " " + obj[1] + " " + obj[2]);
}
public static void main(String[] args){
Object[] myArray1 = {1, "March", 2009};
int[] myArray2 = {9, 1, 1};
print("9", "1", "1");
print(9, 1, 1);
print(new int[] {9, 1, 1}, ", " + 8, 7);
print(myArray1, 9, 2);
print(new Integer[] {9, 1, 1});
print(new String[] {"9", "1", "1"});
print((Object) 9, 1, 1);
print(new Object[] {9, 1, 1});
print(myArray1);
print(myArray2, 9, 3);
print((Object) myArray1, 3, 4);
print(new Object[] {myArray1}, 2, 3);
}
}
- 05-09-2010, 12:29 AM #2
Once is enough
the strangeness of Varargs...
db
-
Duplicate post -- locked.
OP, please don't multipost the same question multiple times as this unnecessarily fragments the discussion and goes against the users agreement which you signed on joining us. Thanks for your cooperation.
Similar Threads
-
weird problem
By GPB in forum New To JavaReplies: 2Last Post: 02-28-2010, 12:04 PM -
Seriously weird output
By gandalf5166 in forum Java AppletsReplies: 4Last Post: 02-27-2010, 04:16 AM -
Weird Error?
By sciguy77 in forum New To JavaReplies: 4Last Post: 01-20-2009, 02:32 AM -
VarArgs Example
By Java Tip in forum java.langReplies: 0Last Post: 04-17-2008, 07:38 PM


LinkBack URL
About LinkBacks

Bookmarks