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.
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.
- duplicates
-
JDK-6253161 Incorrect position of serial warning in anonymous class
-
- Closed
-
- relates to
-
JDK-6322344 Compiler throws misleading error report when interface method implemented in anonymous inner class.
-
- Closed
-