import java.util.*;import java.io.*;import java.lang.*;public class Segment {   public static final int maxSegmentLength = 4;    // hardwired in code :(  Word [] words;    public Segment(Word w1)    { words = new Word [1]; words[0]=w1;    };  public Segment(Word w1,Word w2)    { words = new Word [2];words[0]=w1;words[1]=w2;    };  public Segment(Word w1,Word w2,Word w3)    { words = new Word[3];words[0]=w1;words[1]=w2;words[2]=w3;    };  public Segment(Word w1,Word w2,Word w3,Word w4)    { words = new Word[4];words[0]=w1;words[1]=w2;words[2]=w3;words[3]=w4;    };    public boolean isInteresting()    { if(words[0].isStopword()) return false;      if(!words[words.length-1].isContentWord()) return false;      return true;};  public String toString()     {String s ="";      for(int i=0; i<words.length; i++)         s= s + " " + words[i];      return s;     }   public boolean equals(Object rhs){    if(rhs==null || getClass() != rhs.getClass())      return false;    if(words.length != ((Segment)rhs).words.length)      return false;    for(int i=0; i<words.length; i++)      if(!words[i].equals( ((Segment)rhs).words[i]))        return false;    return true;   };  public int hashCode()    {int sum=0;     for(int i=0; i<words.length; i++)       {sum+= words[i].hashCode(); };     return sum;    };      public static void main(String [] args) {     Word w1= new Word("hund");     Word w2= new Word("dum");     Word w3= new Word("the");     Word w2x= new Word("dum");     Segment s = new Segment(w1,w2,w3);     Segment ss = new Segment(w1,w2x,w3);     System.out.println(s + " " + ss);     if(s.equals(ss)) System.out.println("EQ");     System.out.println(s.hashCode() + " " +  ss.hashCode());     }} 
