title: Why compiler says Works cannot be resolved to a type?
body: <p>I just want to declare a generic type for simple things but the compiler get errors that type is not resolved!
  this is how i did in main:</p>
  
  <pre><code>//Main and Works are in same file
  public class Main {
      public static void main(String[] args) {  
          Works&lt;Integer&gt; a = new Works&lt;Integer&gt;();   //this line got problem
          a.add(2);
          a.add(0);
          a.add(15);
          a.add(-8);
          a.add(6);
          System.out.println(a.getMin());
      }
  }
  </code></pre>
  
  <p>and this is my class declaration
  `</p>
  
  <pre><code>//generic class declaration
  class Works&lt;T extends Comparable&gt; {
      private ArrayList&lt;T&gt; works = new ArrayList&lt;T&gt;();
  
      public void add(T item) {
          works.add(item);
      }
  
      public T getMin() throws IllegalStateException {
          if (works.size() == 0) {
              throw new IllegalStateException("Your task table is empty");
          }
          T tmp = Collections.min(works);
          remove(tmp);
          return tmp;
      }
  
      public Comparable[] getLess(T element, boolean remove) {
          Collections.sort(works);
          if (remove) {
              remove(element);
          }
          return works.subList(0, works.indexOf(element)).toArray();
      }
  }
  </code></pre>
  
  <p>`</p>