Thomas Fritsch <> wrote in message news:<>...
> electric sheep wrote:
>
> >Hi, i'm just curious, is there some way to determine the "most specific"
> >type of an Object type ?
> >
> >For example, the URL's getContent() method returns an Object.
> >Is there a way to "query" that object, and find out if it is a String,
> >or an Image, or whatever ?
> >I'd like to do something like:
> >String foo = (String) my_url.getContent();
> >But I want to make sure I have a String, and not an Image.
> >
> >cheers,
> >e
> >
> Object foo = my_url.getContent();
> if (foo instanceof String)
> {
> String s = (String) foo;
> // do something with s
> }
(Yeuch!)
Casting.
instanceof.
Despisable.
Understandable as the initial question and subsequent answers are,
doesn't this all just show up how nasty that URL.getContent() is?
They should have had a URLContent class with specific methods, and let
Miss Poly Morphism do her stuff.
..ed
www.EdmundKirwan.com