Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-6320556

Bad position for anonymous class

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P4 P4
    • None
    • 5.0
    • tools
    • None
    • generic
    • generic

      This program

           1 import java.util.*;
           2
           3 class Test {
           4 private static ListIterator EMPTYITERATOR = new ListIterator() {
           5 public boolean hasNext() {
           6 return false;
           7 }
           8 public Object next() {
           9 throw new NoSuchElementException();
          10 }
          11 public void remove() {
          12 throw new UnsupportedOperationException();
          13 }
          14 };
          15 }


      gives this error:

      Test.java:11: <anonymous Test$1> is not abstract and does not override abstract method add(java.lang.Object) in java.util.ListIterator
                  public void remove() {
                              ^
      1 error

      The error should have pointed to the class creation on line 4.

            ahe Peter Ahe
            ahe Peter Ahe
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: