Article View: borland.public.jbuilder.java.language
Article #7791Re: rtti
From: Calvin R. Smith
Date: Mon, 14 May 2001 15:30
Date: Mon, 14 May 2001 15:30
22 lines
1387 bytes
1387 bytes
You can do this if myCastVar is a base class of any possible types. if you
don't know a base class then use Object
"rp" <admin@objectpascal.com> wrote in message news:3afefaab$2_1@dnews...
> What I would like to do is cast an object using a variable.
> Is this even possible?
>
> For instance what type would myCastVar be?
>
> ? myCastVar = null;
>
> if(obj instanceof ClassType1) {
> myCastVar = ?;
> }
> else if(obj instanceof ClassType2) {
> myCastVar = ?;
> }
>
> System.out.println( ((myCastVar)obj).getName() );
>
>
>
Technical Details
Message-ID:
<3afffa85_1@dnews>Path:
arc1-ca.pugleaf.net!archiver1.sj.google.com!newsfeed.google.com!sn-xit-02!supernews.com!isdnet!fr.clara.net!heighliner.fr.clara.net!newsfeed01.sul.t-online.de!t-online.de!dnewsReferences:
<3afefaab$2_1@dnews>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: f74b3,c7984d5e71674b17 X-Google-Attributes: gidf74b3,public X-Google-ArrivalTime: 2001-05-14 08:40:36 PST From: "Calvin R. Smith" <calvinrsmith@hotmail.com> Newsgroups: borland.public.jbuilder.java.language References: <3afefaab$2_1@dnews> Subject: Re: rtti Date: Mon, 14 May 2001 09:30:26 -0600 Lines: 24 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 5.50.4133.2400 X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4133.2400 NNTP-Posting-Host: 207.201.104.90 Message-ID: <3afffa85_1@dnews> X-Trace: dnews 989854341 207.201.104.90 (14 May 2001 08:32:21 -0700) Path: arc1-ca.pugleaf.net!archiver1.sj.google.com!newsfeed.google.com!sn-xit-02!supernews.com!isdnet!fr.clara.net!heighliner.fr.clara.net!newsfeed01.sul.t-online.de!t-online.de!dnews