Results 1 to 3 of 3
  1. #1
    Dipke is offline Member
    Join Date
    Aug 2010
    Location
    Leuven, Belgium
    Posts
    86
    Rep Power
    0

    Default Creating array in method parameter

    Hello,

    I want to create an array while giving him to a method (especially the constructor)

    Java Code:
    public Rectangle(int length, int width) {
        //super(length, width);
          super(new int[] = {length, width});
    }
    This code won't work, but it shows what i mean.
    Since super() must be the first keyword i cannot create the array first.
    Is this possible ?

    kind regards

  2. #2
    pbrockway2 is offline Moderator
    Join Date
    Feb 2009
    Location
    New Zealand
    Posts
    4,585
    Rep Power
    12

    Default

    Java Code:
    public Rectangle(int length, int width) {
          super(new int[]{length, width});
    }

  3. #3
    Dipke is offline Member
    Join Date
    Aug 2010
    Location
    Leuven, Belgium
    Posts
    86
    Rep Power
    0

Similar Threads

  1. perfect method parameter/argument match rejected. why?
    By collegestudent115 in forum Advanced Java
    Replies: 5
    Last Post: 10-31-2010, 07:55 PM
  2. Replies: 4
    Last Post: 06-18-2010, 11:08 AM
  3. Replies: 10
    Last Post: 06-12-2009, 07:41 PM
  4. Can a method take itself as parameter?
    By bukake in forum New To Java
    Replies: 10
    Last Post: 09-06-2008, 10:26 PM
  5. Input parameter of Main method
    By Java Tip in forum Java Tip
    Replies: 1
    Last Post: 07-12-2008, 07:24 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
  •