Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>There is a class, which allows the construction of new <code>ListNode</code>s. Each time you construct a <code>ListNode</code> you are required to indicate the <em>type</em> of <code>ListNode</code> you want, where part of the type is a different class that implements the <code>Comparable</code> interface and the other class can be anything.</p> <pre><code>ListNode&lt;Date, String&gt; node = new ListNode&lt;&gt;(); </code></pre> <p>is an example.</p> <p>With such an example, you would then have a <code>ListNode</code> that looked more like:</p> <pre><code>public class ListNode { Date key; String value; ListNode&lt;Date, String&gt; next; ListNode(Date key, String value, ListNode&lt;Date,String&gt; next) { this.key = key; this.value = value; this.next = next; } } </code></pre> <p>The stuff between the <code>&lt;</code> and <code>&gt;</code> is the generic type, and is a feature of Java better known as <a href="http://docs.oracle.com/javase/tutorial/java/generics/" rel="nofollow">"Java Generics"</a>. You should read up on it. It is slightly beyond the scope of a complete explanation within one post, but hopefully the above example will give you an idea. It allows one to write a class that generically takes a pseudo-type-argument.</p> <p><a href="http://docs.oracle.com/javase/7/docs/api/java/lang/Comparable.html" rel="nofollow">The comparable interface</a> is a special interface which provides a linear ordering of some type. For example, you could do alphabetical ordering of Strings, in which case you would have something that looked like</p> <pre><code>public StringComparator implements Comparable&lt;String&gt; .... </code></pre> <p>it works by the <code>Comparable</code> keyword forcing an implementation of a method to be defined.</p> <pre><code>public int compareTo(String other) { ... } </code></pre> <p>Where if the returned integer is negative the other comes before this item, if the returned value is positive, the other comes after this item, and if the returned value is zero, then the two items are (for ordering purposes) equivalent.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload