Results 1 to 6 of 6
  1. #1
    rosh72851 is offline Member
    Join Date
    Sep 2008
    Posts
    58
    Rep Power
    0

    Default Array of objects

    If I have a set of objects, can I construct an object array that contain the the objects. Let me give an example:
    Is this syntax correct?
    Java Code:
    Object a,b,c;
    Object [] Array={a,b,c};

  2. #2
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    19

  3. #3
    Nakira is offline Member
    Join Date
    Oct 2008
    Location
    Aberystwyth
    Posts
    55
    Rep Power
    0

    Default

    If you do this then its good practice. People may know the answers, but if you discover by trying yourslef your more likely to remember in the future.

  4. #4
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    19

    Default

    Yes it is. Just a hint, in most of the materials related to Java I've seen this.

    It's good practice to initialize members before use.

  5. #5
    rosh72851 is offline Member
    Join Date
    Sep 2008
    Posts
    58
    Rep Power
    0

    Default

    thanx,,,
    Ive nulled each element in the array before use.

  6. #6
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    19

    Default

    Quote Originally Posted by rosh72851 View Post
    thanx,,,
    Ive nulled each element in the array before use.
    So is that work? What did you find there? If you can it's better to write them here, because may be someone else can useful your output on that code segment.

Similar Threads

  1. Creating an Array of Objects
    By int80 in forum New To Java
    Replies: 4
    Last Post: 08-09-2011, 12:40 PM
  2. Can I store multiple objects in an array
    By lareauk in forum New To Java
    Replies: 9
    Last Post: 05-29-2008, 03:57 AM
  3. Array of Objects
    By bluefloyd8 in forum New To Java
    Replies: 5
    Last Post: 01-22-2008, 06:27 PM
  4. Array with objects
    By toby in forum New To Java
    Replies: 1
    Last Post: 07-25-2007, 09:50 AM
  5. array of objects
    By Jack in forum New To Java
    Replies: 2
    Last Post: 07-02-2007, 05:24 AM

Posting Permissions

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