Article View: borland.public.jbuilder.java.language
Article #195Re: Array problem
From: Lori M Olson [TeamB]
Date: Thu, 25 May 2006 20:52
Date: Thu, 25 May 2006 20:52
54 lines
2302 bytes
2302 bytes
Raul Lorenzo wrote:
> Hello,
>
> I have this piece of code
> /***************************************************/
> int index=0;
> AttributeREM RoleREM[]=null;
> RoleREM=new AttributeREM[asociationREM.numero_roles];
> RoleREM[index].oid="hello";
> /***************************************************/
>
> Java reports me a null Pointer exception at RoleREM[index].oid="hello";
> Why?
> asociationREM.numero_roles is always >0
>
> AttributeREM is a class something like this
>
> class AttributeREM
> {
> public String oid;
> public String name;
> ...
> ...
> };
>
> Thanks in advance
>
This statement:
RoleREM=new AttributeREM[asociationREM.numero_roles];
Creates an array, but it does not populate the array with instances of
AttributeREM. The contents of the array will all be null, until you put
something in it.
--
Regards,
Lori Olson [TeamB]
------------
Save yourself, and everyone else, some time and search the
newsgroups and the FAQ-O-Matic before posting your next
question.
Google Advanced Newsgroup Search
http://www.google.ca/advanced_group_search
Other Newsgroup Searches:
http://www.borland.com/newsgroups/ngsearch.html
Joi Ellis's FAQ-O-Matic:
http://www.visi.com/~gyles19/fom-serve/cache/1.html
Technical Details
Message-ID:
<44761903$1@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!g2news2.google.com!news3.google.com!border1.nntp.dca.giganews.com!border2.nntp.dca.giganews.com!nntp.giganews.com!newspeer1.nwr.nac.net!news-out.nuthinbutnews.com!sp6iad.superfeed.net!in2.nntp.be!caladan.landsraad.net!newsgroups.borland.com!not-for-mailReferences:
<4475f04d@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Thread: f74b3,a661d771a96526a0 X-Google-Attributes: gidf74b3,public X-Google-Language: ENGLISH,ASCII-7-bit Subject: Re: Array problem From: "Lori M Olson [TeamB]" <javadragon@techie.com> Date: Thu, 25 May 2006 14:52:24 -0600 Message-ID: <44761903$1@newsgroups.borland.com> References: <4475f04d@newsgroups.borland.com> Lines: 54 NNTP-Posting-Host: 198.161.239.123 Path: arc1-ca.pugleaf.net!g2news2.google.com!news3.google.com!border1.nntp.dca.giganews.com!border2.nntp.dca.giganews.com!nntp.giganews.com!newspeer1.nwr.nac.net!news-out.nuthinbutnews.com!sp6iad.superfeed.net!in2.nntp.be!caladan.landsraad.net!newsgroups.borland.com!not-for-mail Newsgroups: borland.public.jbuilder.java.language X-Trace: newsgroups.borland.com 1148590339 198.161.239.123 (25 May 2006 13:52:19 -0700) User-Agent: Thunderbird 1.5.0.2 (Macintosh/20060308) MIME-Version: 1.0 In-Reply-To: <4475f04d@newsgroups.borland.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit