Passing array-object

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Michael Isaksson

    Passing array-object

    Hello!

    I want to know how to passing an array-object from a function..

    I have a class called brickCollection , in this class i have a function
    called getBricks() which a JFrame object should use to paint the bricks that
    the brickCollection holds.


    I tried with this, but it didn't work.

    public brick[] getBricks()
    {
    return brick[];
    }

    Hope someone could help!

    Regards,

    Michael


  • Joshua

    #2
    Re: Passing array-object

    On Thu, 03 Aug 2006 18:13:14 +0000, Michael Isaksson wrote:
    Hello!
    >
    I want to know how to passing an array-object from a function..
    >
    I have a class called brickCollection , in this class i have a function
    called getBricks() which a JFrame object should use to paint the bricks that
    the brickCollection holds.
    >
    >
    I tried with this, but it didn't work.
    >
    public brick[] getBricks()
    {
    return brick[];
    }
    >
    Hope someone could help!
    >
    Regards,
    >
    Michael
    This should work:

    public class brickCollection {
    private brick[] bricks;
    // Other variables, methods, and whatnot
    public brick[] getBricks() {
    return bricks;
    }
    }

    (In public API's, though, this isn't a very good practice to follow
    generally, but thats beside the point...)

    Comment

    • Michael Isaksson

      #3
      Re: Passing array-object

      Nice! Thank you!

      //Michael
      "Joshua" <Pidgeot18@gmai l.comwrote in message
      news:pan.2006.0 8.03.19.54.16.5 27730@gmail.com ...
      On Thu, 03 Aug 2006 18:13:14 +0000, Michael Isaksson wrote:
      >
      >Hello!
      >>
      >I want to know how to passing an array-object from a function..
      >>
      >I have a class called brickCollection , in this class i have a function
      >called getBricks() which a JFrame object should use to paint the bricks
      >that
      >the brickCollection holds.
      >>
      >>
      >I tried with this, but it didn't work.
      >>
      >public brick[] getBricks()
      >{
      > return brick[];
      >}
      >>
      >Hope someone could help!
      >>
      >Regards,
      >>
      >Michael
      >
      This should work:
      >
      public class brickCollection {
      private brick[] bricks;
      // Other variables, methods, and whatnot
      public brick[] getBricks() {
      return bricks;
      }
      }
      >
      (In public API's, though, this isn't a very good practice to follow
      generally, but thats beside the point...)

      Comment

      Working...