How to createan empty list that is associated with the specified comparator (java)? -
my question mysortedlinkedlist constructor...i know head=null; empty list, don't know how include comparator.
you need assign field:
public class mysortedlinkedlist<t> implements iterable<t> { private mylistnode<t> head; private final comparator<t> comparator; public mysortedlinkedlist(comparator<t> comparator) { head = null; this.comparator = comparator; } }
you can't without introducing field - it's part of differentiates 1 instance another.
Comments
Post a Comment