I want to know that, how can i define my return type?
public Myreturntype fun1()
As i have already used predefined Return type like String,int But I want to know How can We make My return type?"
Actually, i was Confused with the Iterator Method in Arraylist like "Iterator itr = ArrayList.iterator();" In The ArrayList It has one of method "public Iterator iterator()" . But i m not getting How the Arraylist implements This iterator() function Because the Iterator is a interface and has only three methods boolean hasNext(), Object next() ,void remove().
As i am thinking In the Arraylist Its written like that Or something else??
public class Arraylist extends AbstarctList implements List, RandomAccess, Cloneable
public Iterator iterator()
Iterator it=new Arraylist ();
That is how I would do it, with an anonymous class. To find out more, unzip the file called src.zip which is in your Java installation directory and explore that. If I remember correctly, that ListIterator<T> interface extends Iterator.
Joined: Jul 08, 2012
please Clear me one more things that if i am doing like it "HashSet s = new HashSet();" instead of "Set s = new HashSet();".
Is there Any problem?? Or Any Suggestion you can give me as A programming concept?
Joined: Oct 13, 2005
It is best to use
Set<Foo> mySet = new HashSet<Foo>(); …because you can change the implementation of the set to a TreeSet very simply.