Article View: borland.public.jbuilder.java.language
Article #7429Re: How to define/use array of records (user-defined types)?
From: swett
Date: Fri, 22 Jun 2001 19:04
Date: Fri, 22 Jun 2001 19:04
45 lines
2286 bytes
2286 bytes
No problem anymore. Thanks to the help I received here and digging a little
deeper in my "Beginning Java 2" book by Wrox the problem was isolated. I
think it was due to not having a constructor method in my class definition.
With the class def shown below, everything is now working fine for me. The
Description variable must have been null before.
class ItemData
{
// Instance variables:
int Number = 0;
String Description = new String();
double Cost = 0.0;
// Constructor method:
ItemData()
{
Number = 0;
Description = "";
Cost = 0.0;
} // ItemData() method
} // ItemData class
>
> > I've tried the following before and was still encountering a problem:
> >
> > ItemData[] myItemDataArray = new ItemData[50];
> > ItemData myItemData = new ItemData( ); // one object
> > myItemData.Number = 575;
> > myItemData.Description = "widget";
> > myItemData.Cost = 29.95;
> > myItemDataArray[0] = myItemData;
>
> I see that you have fixed the original problem. What sort of problem
> are you having now?
>
> --
> Regards,
>
> John McGrath [TeamB]
>
> ---------------------------------------------------
> Before sending me e-mail, please read:
> http://www.JPMcGrath.net/newsgroups/e-mail.html
Technical Details
Message-ID:
<3b33998a_2@dnews>Path:
arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!newsfeed.google.com!sn-xit-02!supernews.com!newsfeed.direct.ca!look.ca!newsfeed.wirehub.nl!PeerFeed.KWeb.on.ca!dnewsReferences:
<3b315178_1@dnews> <3b318771$1_2@dnews> <3b326283_2@dnews> <MPG.159c74dbea28fa8398a2c9@forums.borland.com>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: f74b3,f38dc19b99e1adb5 X-Google-Attributes: gidf74b3,public X-Google-ArrivalTime: 2001-06-22 12:19:12 PST Reply-To: <swett@bcswebsite.com> From: <swett@starband.com> Newsgroups: borland.public.jbuilder.java.language References: <3b315178_1@dnews> <3b318771$1_2@dnews> <3b326283_2@dnews> <MPG.159c74dbea28fa8398a2c9@forums.borland.com> Subject: Re: How to define/use array of records (user-defined types)? Date: Fri, 22 Jun 2001 15:04:52 -0400 Lines: 47 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 5.50.4522.1200 X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4522.1200 NNTP-Posting-Host: 148.71.34.6 Message-ID: <3b33998a_2@dnews> X-Trace: dnews 993237386 148.71.34.6 (22 Jun 2001 12:16:26 -0700) Path: arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!newsfeed.google.com!sn-xit-02!supernews.com!newsfeed.direct.ca!look.ca!newsfeed.wirehub.nl!PeerFeed.KWeb.on.ca!dnews