Article View: chile.comp.programacion
Article #2644Re: JAVA: Como saber que interfaz implementa un objeto?
From: Rodrigo Barrientos L.
Date: Wed, 19 Oct 2005 21:45
Date: Wed, 19 Oct 2005 21:45
23 lines
1603 bytes
1603 bytes
Miguel Farah F. <NOmigSPuelAM@lj.cl> wrote:
> Tengo un m?todo en una clase que recibe como par?metro un objeto
> *cualquiera*, y quiero hacer algunas cosas dependiendo de qu? cosa sea.
El operador
<objecto> instanceof <clase>
entrega un booleano que indica si el objeto es del tipo clase
(clases o interfaces, da lo mismo).
En tu caso,
Vector v=new Vector();
System.out.println(v instanceof java.util.List);
--
[Signature changing tool.. to proceed, press 'Shift-C-^T', then enter
'Abracadabra', then..]
You probably wouldn't worry about what people think of you if you could
know how seldom they do.
-- Olin Miller.
Technical Details
Message-ID:
<dj6eq1$kmh$1@helcaraxe.dcc.uchile.cl>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!news.glorb.com!nntp-server.pubsub.com!news1.nivel5.cl!news.cec.uchile.cl!helcaraxe.dcc.uchile.cl!not-for-mailReferences:
<4356be33@news.vcd.cl>Show Full Headers
Complete Article Headers
X-Google-Thread: 1593cb,367c655475693dfc
X-Google-Attributes: gid1593cb,public
X-Google-Language: ENGLISH,ASCII-7-bit
Path: arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!news.glorb.com!nntp-server.pubsub.com!news1.nivel5.cl!news.cec.uchile.cl!helcaraxe.dcc.uchile.cl!not-for-mail
From: "Rodrigo Barrientos L." <robarrie@dcc.uchile.cl>
Newsgroups: chile.comp.programacion
Subject: Re: JAVA: Como saber que interfaz implementa un objeto?
Date: Wed, 19 Oct 2005 21:45:37 +0000 (UTC)
Organization: DCC - Universidad de Chile
Lines: 23
Message-ID: <dj6eq1$kmh$1@helcaraxe.dcc.uchile.cl>
References: <4356be33@news.vcd.cl>
NNTP-Posting-Host: anakena.dcc.uchile.cl
X-Trace: helcaraxe.dcc.uchile.cl 1129758337 21201 192.80.24.6 (19 Oct 2005 21:45:37 GMT)
X-Complaints-To: newsmaster@dcc.uchile.cl
NNTP-Posting-Date: Wed, 19 Oct 2005 21:45:37 +0000 (UTC)
User-Agent: tin/1.6.2-20030910 ("Pabbay") (UNIX) (Linux/2.6.10-gentoo-r6 (i686))