我遇到了以下我不认识的 Java 语法。
这部分很好:
public abstract class Stream<T> implements Iterator<T> {
public boolean hasNext() {
return true; }
public void remove() {
throw new RuntimeException("Unsupported Operation"); }
}
但这我不明白:
Stream<Integer> ones = new Stream<Integer>() {
public Integer next() {
return 1; }
};
while(true){
System.out.print(ones.next() + ", ");
}
这是什么?