Article View: cn.bbs.comp.lang.java
Article #23689Java为什么自动作了wrap的操作?
From: StevenZhao
Date: Mon, 14 Jul 2003 09:51
Date: Mon, 14 Jul 2003 09:51
119 lines
5493 bytes
5493 bytes
This is a multi-part message in MIME format.
------=_NextPart_000_0041_01C34A30.93E7BF30
Content-Type: text/plain;
charset="gb2312"
Content-Transfer-Encoding: quoted-printable
=D4=DA=CF=C2=C3=E6=B3=CC=D0=F2=D6=D0=A3=AC=CA=E4=C8=EB=B2=CE=CA=FD=CA=C7=D2=
=BB=B8=F6int[]=A3=AC=B5=AB=CA=C7=BE=AD=B9=FD=D7=D4=BC=BAimplements=B5=C4E=
numeration=D6=AE=BA=F3=A3=AC=CB=F9=D3=D0=B5=C4int=B1=E4=B3=C9=C1=CBIntege=
r=A3=AC=D5=E2=CA=C7=CE=AA=CA=B2=C3=B4=A3=BF
import java.util.Enumeration;
import java.lang.reflect.Array;
public class EnumerationLearning implements Enumeration
{
private final int size;
private int cursor;
private final Object array;
public EnumerationLearning(Object obj)
{
Class type =3D obj.getClass();
if(!type.isArray())
{
throw new IllegalArgumentException("type :"+type); =20
}
size =3D Array.getLength(obj);
array =3D obj;
}
=20
public boolean hasMoreElements()
{
return (cursor<size);
}
=20
public Object nextElement()
{
return Array.get(this.array,cursor++);
}
public static void main(String[] args)
{
int[] array =3D new int[2];
array[0] =3D 2;
array[1] =3D 3;
EnumerationLearning enu =3D new =
EnumerationLearning(array);//=CA=E4=C8=EB=B5=C4=CA=C7int[]
while(enu.hasMoreElements())
{
=
if(enu.nextElement().getClass().equals(Integer.class))//=CA=E4=B3=F6=B5=C4=
=CA=FD=D7=E9=D4=AA=CB=D8=B1=E4=B3=C9Integer=C1=CB
{
System.out.println("yes");
}
}
}
}
------=_NextPart_000_0041_01C34A30.93E7BF30
Content-Type: text/html;
charset="gb2312"
Content-Transfer-Encoding: quoted-printable
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=3DContent-Type content=3D"text/html; charset=3Dgb2312">
<META content=3D"MSHTML 6.00.2800.1170" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY>
<DIV><FONT=20
size=3D2>=D4=DA=CF=C2=C3=E6=B3=CC=D0=F2=D6=D0=A3=AC=CA=E4=C8=EB=B2=CE=CA=FD=
=CA=C7=D2=BB=B8=F6int[]=A3=AC=B5=AB=CA=C7=BE=AD=B9=FD=D7=D4=BC=BAimplemen=
ts=B5=C4Enumeration=D6=AE=BA=F3=A3=AC=CB=F9=D3=D0=B5=C4int=B1=E4=B3=C9=C1=
=CBInteger=A3=AC=D5=E2=CA=C7=CE=AA=CA=B2=C3=B4=A3=BF</FONT></DIV>
<DIV><FONT size=3D2></FONT> </DIV>
<DIV><FONT size=3D2>import java.util.Enumeration;<BR>import=20
java.lang.reflect.Array;</FONT></DIV>
<DIV><FONT size=3D2></FONT> </DIV>
<DIV><FONT size=3D2>public class EnumerationLearning implements=20
Enumeration<BR>{<BR> private final int size;<BR> private int =
cursor;<BR> private final Object array;<BR> public=20
EnumerationLearning(Object obj)<BR> {<BR> Class =
type =3D=20
obj.getClass();<BR> =
if(!type.isArray())<BR> =20
{<BR> throw new =
IllegalArgumentException("type=20
:"+type); <BR> }<BR> size =3D=20
Array.getLength(obj);<BR> array =3D obj;<BR> =
}<BR> =20
<BR> public boolean hasMoreElements()<BR> =
{<BR> =20
return (cursor<size);<BR> }<BR> <BR> public Object=20
nextElement()<BR> {<BR> return=20
Array.get(this.array,cursor++);<BR> }<BR> public static void =
main(String[] args)<BR> {<BR> int[] array =3D =
new=20
int[2];<BR> array[0] =3D 2;<BR> =
array[1] =3D=20
3;<BR> <FONT color=3D#ff0000>EnumerationLearning enu =
=3D new=20
EnumerationLearning(array);//=CA=E4=C8=EB=B5=C4=CA=C7int[]<BR></FONT>&nbs=
p; =20
while(enu.hasMoreElements())<BR> =20
{<BR> <FONT=20
color=3D#ff0000>if(enu.nextElement().getClass().equals(Integer.class))//=CA=
=E4=B3=F6=B5=C4=CA=FD=D7=E9=D4=AA=CB=D8=B1=E4=B3=C9Integer=C1=CB<BR> =
; =20
{<BR> =20
System.out.println("yes");<BR> =20
}<BR></FONT> }<BR> }</FONT></DIV>
<DIV><FONT size=3D2></FONT> </DIV>
<DIV><FONT size=3D2>}</FONT></DIV></BODY></HTML>
------=_NextPart_000_0041_01C34A30.93E7BF30--
Technical Details
Message-ID:
<betufe$1h4q$1@mail.cn99.com>Path:
arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-04!sn-xit-06!sn-xit-08!supernews.com!207.217.77.43.MISMATCH!elnk-pas-nf1!elnk-pas-nf2!newsfeed.earthlink.net!newshub.sdsu.edu!logbridge.uoregon.edu!newsgate.cuhk.edu.hk!news.cn99.com!not-for-mailShow Full Headers
Complete Article Headers
X-Google-Language: Chinese,GB X-Google-Thread: f6cb0,68011d663a596351,start X-Google-Attributes: gidf6cb0,public X-Google-ArrivalTime: 2003-07-14 02:52:05 PST Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-04!sn-xit-06!sn-xit-08!supernews.com!207.217.77.43.MISMATCH!elnk-pas-nf1!elnk-pas-nf2!newsfeed.earthlink.net!newshub.sdsu.edu!logbridge.uoregon.edu!newsgate.cuhk.edu.hk!news.cn99.com!not-for-mail From: "StevenZhao" <steven.j.zhao@263.net> Newsgroups: cn.bbs.comp.lang.java Subject: Java为什么自动作了wrap的操作? Date: Mon, 14 Jul 2003 17:51:39 +0800 Organization: Bentium Ltd. (CN99) Lines: 120 Message-ID: <betufe$1h4q$1@mail.cn99.com> NNTP-Posting-Host: 61.149.20.98 Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_NextPart_000_0041_01C34A30.93E7BF30" X-Trace: mail.cn99.com 1058176303 50330 61.149.20.98 (14 Jul 2003 09:51:43 GMT) X-Complaints-To: usenet@news.cn99.com NNTP-Posting-Date: Mon, 14 Jul 2003 09:51:43 +0000 (UTC) X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2800.1158 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165