Comparison method violates its general contract- overlapping conditions
<p>I'm stuck in a exception where java complains the comparison method is wrong. </p>

<p>Here's the rules: 
I defined a class called match. Imagine searching through 2 sequences to find identical substrings. If there exists 2 identical substrings, call it a match. The score is how long the substring is, and seq1/2 start/end marks where the 2 substrings begin and end. The goal is to pick the longest substring match. If the 2 matches have the same score, I'll pick a match that starts earlier in both sequences. Otherwise I ignore the rest by making them equal to each other. </p>

<p>Here's the code that's wrong:</p>

<pre><code>public class CompareMatch implements Comparator&lt;match&gt;{
    @Override
    public int compare(match o1, match o2) {
    if(o1.score&gt;o2.score)   return -1;
    if ((o1.score==o2.score)&amp;&amp;((o1.seq1start&lt;o2.seq1start)&amp;&amp;(o1.seq2start&lt;o2.seq2start))) 
        return -1;
    if((o1.score==o2.score)&amp;&amp;!((o1.seq1start&lt;o2.seq1start)&amp;&amp;(o1.seq2start&lt;o2.seq2start)))
        return 0;
    return 1;
    }
}
</code></pre>

<p>Also the match class is defined as follows:</p>

<pre><code>public class match {
    public int seq1start;
    public int seq1end;
    public int seq2start;
    public int seq2end;
    public int score;
    }
</code></pre>

<p>Can someone help me pick out which part of the comparison logic is wrong? I must have overlapped one of the conditions. Thanks</p>
