Article View: borland.public.jbuilder.java.language
Article #197Re: Array problem
From: Alexey N. Solofnenko
Date: Sat, 27 May 2006 04:17
Date: Sat, 27 May 2006 04:17
49 lines
2348 bytes
2348 bytes
In Java all object variables are actually similar to C++ pointers. So,
when you create AttributeREM* array you will also get an array of nulls.
- Alexey.
Raul Lorenzo wrote:
> Ok, It´s like C++.....I think Java create all the structure automátically.
> Thanks
>
> Lori M Olson [TeamB] escribió:
>> 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.
>>
--
Alexey N. Solofnenko
home: http://trelony.cjb.net/
Technical Details
Message-ID:
<4477d1fb@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!g2news2.google.com!news3.google.com!news4.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newscon06.news.prodigy.com!prodigy.net!news-out.nuthinbutnews.com!sp6iad.superfeed.net!in2.nntp.be!caladan.landsraad.net!newsgroups.borland.com!not-for-mailReferences:
<4475f04d@newsgroups.borland.com> <44761903$1@newsgroups.borland.com> <447706bc@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Thread: f74b3,a661d771a96526a0 X-Google-Attributes: gidf74b3,public X-Google-Language: ENGLISH,UTF8 Subject: Re: Array problem From: "Alexey N. Solofnenko" <nospam@nospam.comp> Date: Fri, 26 May 2006 21:17:58 -0700 Message-ID: <4477d1fb@newsgroups.borland.com> References: <4475f04d@newsgroups.borland.com> <44761903$1@newsgroups.borland.com> <447706bc@newsgroups.borland.com> Lines: 49 NNTP-Posting-Host: 24.4.135.226 Path: arc1-ca.pugleaf.net!g2news2.google.com!news3.google.com!news4.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newscon06.news.prodigy.com!prodigy.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 1148703227 24.4.135.226 (26 May 2006 21:13:47 -0700) User-Agent: Thunderbird 2.0a1 (X11/20060525) MIME-Version: 1.0 In-Reply-To: <447706bc@newsgroups.borland.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit