The Artima Developer Community
Sponsored Link

Legacy Java Answers Forum
December 2000

Advertisement

Advertisement

This page contains an archived post to the Java Answers Forum made prior to February 25, 2002. If you wish to participate in discussions, please visit the new Artima Forums.

Message:

Where r the methods of the enumeration interface

Posted by Minaz on January 09, 2001 at 10:25 AM

> > > Hi Saddy
> > > Please send me the program you are talking about. There are things in Java which is not permitted if we , the programmer , do it but in internally they are. For example the two modifiers "abstract" and "final" cannot be used with a class. But when you declare an array of int ( in fact for any array ) like
> > > int[] arr = new int[50] ;
> > > now when you try to find the class of arr in it is
> > > public abstract final [I ...

> > > So, you may be right if the program you are referring to has been written by the creator of Java themselves...

> > > Thanx
> > > Kishori

> > Hi Kishori,
> > here is the program that i was talking about

> >
> > class vectors{
> > public static void main(String args[])
> > {
> > Vector a = new Vector();
> >
> > a.addElement(new String("Hello"));
> > a.addElement(new String(" to"));
> > a.addElement(new String(" this"));
> > a.addElement(new String(" World"));
> >
> > Enumeration vEnum = a.elements();
> > while(vEnum.hasMoreElements())
> > {
> > System.out.print(vEnum.nextElement());
> > }
> > }
> > }

> > Here hasMoreElements() and nextElement() both of Enumeration interface are used without overriding them, how is it working?
> > i will be thankful if u could clear my doubt

> > saddy

>
> Your doubt is very good ...
> Vector object . elements() returns an object of a class which is implementing the interface Enumeration...
> i hope u already know that an interface can hold an object reference of its subclass so that happened here ....
> but the name of the subclass of that interface Enumeration is not disclosed...

> so that's it u can mail me if u have any doubts...
> bye

> Spidy...

U er answer is very convincing. But does the enumeration interface has its own methods & if so in the above code of vector class where r we overriding it.




Replies:

Sponsored Links



Google
  Web Artima.com   
Copyright © 1996-2009 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use - Advertise with Us