Article View: borland.public.jbuilder.java.language
Article #17849Re: how to instantiate n objects during runtime?
From: yunj
Date: Thu, 10 Sep 1998 00:00
Date: Thu, 10 Sep 1998 00:00
32 lines
2022 bytes
2022 bytes
In article <35CFCCCB.42DC4D35@worldnet.att.net>,
John Niesz <sunrunner15@worldnet.att.net> wrote:
> just store them in a Vector, using the addElement(Object myObj) function in
> the loop, and when you read the objects from the Vector, make sure you cast
> them appropriately: ((MyObj)(vec.elementAt(index)));
>
> Mariano Belinky wrote:
>
> > how can I instantiate n objects in runtime? for example, I pass and int
> > arg to a for and the loop will instantiate that "quantity" of objects.
> >
> > Mariano
>
>
I read the Visual Cafe 2.5a notes on vector.addElement and looked at examples
in books. They give examples, such as v1.addElement("four") or v1.addElement
(new Integer(1)). But what I really need to know is how do I add my own user
developed objects? I get an error message:
"Exception occured during event dispatching:
java.lang.NullPointerException"
It compiles fine. The object only holds 3 strings. Any ideas what I'm doing
wrong? Vector MyVector; CPerson MyPerson; CPerson.Name = "Jim";
MyVector.add(MyPerson); <-- this compiles fine, but I get a runtime
exception that isn't displayed.
Thanks,
Jairo
-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/rg_mkgrp.xp Create Your Own Free Member Forum
Technical Details
Message-ID:
<6t9dfu$u6k$1@nnrp1.dejanews.com>Path:
arc1-ca.pugleaf.net!unknown!not-for-mailReferences:
<35C0B31A.67C3E6C4@lacapitaldelplata.com.ar> <35CFCCCB.42DC4D35@worldnet.att.net>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: f74b3,346c7386d6fb7b82 X-Google-Attributes: gidf74b3,public From: yunj@my-dejanews.com Subject: Re: how to instantiate n objects during runtime? Date: 1998/09/10 Message-ID: <6t9dfu$u6k$1@nnrp1.dejanews.com> X-Deja-AN: 389844267 References: <35C0B31A.67C3E6C4@lacapitaldelplata.com.ar> <35CFCCCB.42DC4D35@worldnet.att.net> X-Http-Proxy: 1.0 ESXNYFWL01, 1.0 x12.dejanews.com:80 (Squid/1.1.22) for client 206.175.89.84 Organization: Deja News - The Leader in Internet Discussion X-Article-Creation-Date: Thu Sep 10 20:40:30 1998 GMT Newsgroups: borland.public.jbuilder.java.language X-Http-User-Agent: Mozilla/4.0 (compatible; MSIE 4.01; Windows NT)