🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.jbuilder.java.language
Article #17240

Array of objects

#17240
From: Claire Kennedy
Date: Mon, 07 Dec 1998 00:00
31 lines
1432 bytes
I am trying to implement an array of objects simliar to an array of
structures in c++.  I can't find examples of this in any books could
someone tell me if I'm going about it the correct way.  Or if someone
knows where I could find an example could they please tell me.

This is the class used to hold the structure:

public class ClientInfo {
       public String clientname = null;
       public String clienttype = null;
       public String acctotal = null;
}

And this is the application implementing an array of this ClientInfo.

public class GridFrame extends ClientInfo
{
   static ClientInfo clients[] = new ClientInfo[5];

  public static void main(String[] args)
  {
        clients[0].clientname = ("Claire");
        clients[0].clienttype = ("1");
        clients[0].acctotal = ("2");
  }
}

I keep getting a null pointer exception I presume this has something to
do with the way I am referencing the variables in the class.
Thanks
Claire
Technical Details
Message-ID: <366BB72E.D50DB329@ifs.ie>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f74b3,74fc4ddd4c7ec393,start
X-Google-Attributes: gidf74b3,public
From: Claire Kennedy <claire.kennedy@ifs.ie>
Subject: Array of objects
Date: 1998/12/07
Message-ID: <366BB72E.D50DB329@ifs.ie>
X-Deja-AN: 419591097
Content-Transfer-Encoding: 7bit
Organization: Indigo
Content-Type: text/plain; charset=us-ascii
Mime-Version: 1.0
Newsgroups: borland.public.jbuilder.java.language