🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.jbuilder.java.language
Article #7648

Re: About class cast.

#7648
From: ainur
Date: Fri, 01 Jun 2001 18:04
32 lines
1843 bytes
the object Class (it exists) has a methode that returns/loads a class of the
type mentioned in the name-string

Try using:

try {
        MyClass instanceOfMyClass = Class.forName(className);

}catch(ClassNotFoundException exc) {

}

if you find a better (nicer) way, please let me know

Succes.

----- Original Message -----
From: <wuliao999 no>
Newsgroups: borland.public.jbuilder.java.language
Sent: Thursday, May 31, 2001 9:51 AM
Subject: About class cast.


>
> I get a class name from a string, for example:
> String className="com.borland.myClass";
> how can I cast an objects' type to this?
<wuliao999 no> schreef in bericht news:3b15f7e6$1_2@dnews...
>
> I get a class name from a string, for example:
> String className="com.borland.myClass";
> how can I cast an objects' type to this?
Technical Details
Message-ID: <991418451.11276.0.pluto.c3adee5c@news.demon.nl>
Path: arc1-ca.pugleaf.net!archiver1.google.com!newsfeed.google.com!sn-xit-02!supernews.com!nntp-relay.ihug.net!ihug.co.nz!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!newsfeed.icl.net!dispose.news.demon.net!news.demon.nl!demon!ainur.demon.nl!not-for-mail
References: <3b15f7e6$1_2@dnews>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f74b3,25286dd36905df6c
X-Google-Attributes: gidf74b3,public
X-Google-ArrivalTime: 2001-06-01 11:01:03 PST
Path: arc1-ca.pugleaf.net!archiver1.google.com!newsfeed.google.com!sn-xit-02!supernews.com!nntp-relay.ihug.net!ihug.co.nz!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!newsfeed.icl.net!dispose.news.demon.net!news.demon.nl!demon!ainur.demon.nl!not-for-mail
From: <ainur>
Newsgroups: borland.public.jbuilder.java.language
Subject: Re: About class cast.
Date: Fri, 1 Jun 2001 20:04:29 +0200
Message-ID: <991418451.11276.0.pluto.c3adee5c@news.demon.nl>
References: <3b15f7e6$1_2@dnews>
NNTP-Posting-Host: ainur.demon.nl
X-NNTP-Posting-Host: ainur.demon.nl:195.173.238.92
X-Trace: news.demon.nl 991418451 pluto:11276 NO-IDENT ainur.demon.nl:195.173.238.92
X-Complaints-To: abuse@nl.demon.net
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 5.00.2919.6700
X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2919.6700
Lines: 34