Results 1 to 3 of 3
  1. #1
    vlad is offline Member
    Join Date
    May 2010
    Location
    Colorado
    Posts
    6
    Rep Power
    0

    Default 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);
    }
    }

  2. #2
    DarrylBurke's Avatar
    DarrylBurke is offline Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,193
    Rep Power
    19

    Default

    Once is enough
    the strangeness of Varargs...

    db

  3. #3
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default

    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

  1. weird problem
    By GPB in forum New To Java
    Replies: 2
    Last Post: 02-28-2010, 12:04 PM
  2. Seriously weird output
    By gandalf5166 in forum Java Applets
    Replies: 4
    Last Post: 02-27-2010, 04:16 AM
  3. Weird Error?
    By sciguy77 in forum New To Java
    Replies: 4
    Last Post: 01-20-2009, 02:32 AM
  4. VarArgs Example
    By Java Tip in forum java.lang
    Replies: 0
    Last Post: 04-17-2008, 07:38 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •