Article View: borland.public.jbuilder.java.language
Article #15066Dynamic class selection at run time.
From: Barry Kelliher
Date: Thu, 15 Jul 1999 00:00
Date: Thu, 15 Jul 1999 00:00
22 lines
1387 bytes
1387 bytes
Hi, I would like to know if the following can be done. I have a single class "class A" which is extended by several classes. I originally create a object which is an instance of class A. |The constructor for this class names in it arguments a string which is derived from user interaction at run time. Once a new instance of Class A is created I then want to create an instance of one of the child classes by casting. which child class I chose to use is determined by one of the previously mentioned user input. Ok, can I create the instance of the required class with out using a switch or if statement? ie can I specify the required class dynamically based on the value previously mentioned user input. in the statement ClassName n = new ClassName(); I want to dynamically substitute ClassName at run time. Thanks in advance Barry
Technical Details
Message-ID:
<7mk8k5$4sg9@forums.borland.com>Path:
arc1-ca.pugleaf.net!unknown!not-for-mailShow Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: f74b3,162f723987f8c188,start X-Google-Attributes: gidf74b3,public From: "Barry Kelliher" <bkelli01@clear.net.nz> Subject: Dynamic class selection at run time. Date: 1999/07/15 Message-ID: <7mk8k5$4sg9@forums.borland.com> X-Deja-AN: 501265048 X-Priority: 3 X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2014.211 Organization: Another Netscape Collabra Server User X-MSMail-Priority: Normal Newsgroups: borland.public.jbuilder.java.language