Hello Sir ,
As i m a beginner I have some queries with in basic of java J2se.i am basically confused in the rule of interface example if we want to create ab object of ArrayList......
ArrayList ar=new ArrayList(Collection c);
here c is the object(refrence variable) of Collection. then why it is possible to use or pass the objects(in below example object v) of other(like ArrayList,Vector,LinkedList etc) classes which is implementing the the Collection interface in this constructor
eg... Vector v=new Vector();
v.add("aaa");
v.add("bbb");
ArrayList ar=new ArrayList(v);
we can only use the Object of Collection interface then how can it be possible topass other classes objects it is not according to rule passing paramenters
i have also tried passing (interface)Enumeration object (refrence variable) in
Vector v=new Vector();
Enumeration e=v.elements();
SequenceInputestream in=new SequenceInputestream (e);
is correct but when i tried to pass the object of StringTokenizer(this class implements Enemuration interface same as Vector implements Collection Interface) it did't work
hope u know my query and will reply me
|