Article View: borland.public.jbuilder.java.api
Article #2063Re: String[] casting of other arrays
From: Michael Rachow
Date: Mon, 04 Jun 2001 07:19
Date: Mon, 04 Jun 2001 07:19
28 lines
1652 bytes
1652 bytes
Hi Yonatan, In general: You can assign a reference to any class above the inheritance tree and to any interface any of these classes is implementing without a cast. A reference stored at any of these more general types can be casted "back" to a more specialized type down to the original. Here cast is a must. At any point the reference is the original object (will show if it is asked for). By casting you cannot "change" an object like it works in some respect in C/C++. Greetings Michael. Yonatan Taub <yonatanta@bashan.co.il> schrieb in im Newsbeitrag: 3b1a7545_1@dnews... > Is it possible to do something like the following? > > String[] strArray = (String[])objArr; > > Offcourse this doesn't work, but is there a short and ellegant way to > implement such an idea (without iteration!)? > >
Technical Details
Message-ID:
<3b1b3609_1@dnews>Path:
arc1-ca.pugleaf.net!archiver1.google.com!newsfeed.google.com!sn-xit-02!supernews.com!newsfeed.direct.ca!look.ca!newsfeed.wirehub.nl!PeerFeed.KWeb.on.ca!dnewsReferences:
<3b1a7545_1@dnews>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 1089d0,4cd3fd58a543ecae X-Google-Attributes: gid1089d0,public X-Google-ArrivalTime: 2001-06-04 00:37:57 PST From: "Michael Rachow" <michael@famrachow.de> Newsgroups: borland.public.jbuilder.java.api References: <3b1a7545_1@dnews> Subject: Re: String[] casting of other arrays Date: Mon, 4 Jun 2001 09:19:47 +0200 Lines: 30 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 5.00.2615.200 X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2615.200 NNTP-Posting-Host: 217.81.82.18 Message-ID: <3b1b3609_1@dnews> X-Trace: dnews 991639049 217.81.82.18 (4 Jun 2001 00:17:29 -0700) Path: arc1-ca.pugleaf.net!archiver1.google.com!newsfeed.google.com!sn-xit-02!supernews.com!newsfeed.direct.ca!look.ca!newsfeed.wirehub.nl!PeerFeed.KWeb.on.ca!dnews