java.util.NoSuchElementException.<init>()方法的使用及代码示例

x33g5p2x  于2022-01-24 转载在 其他  
字(4.2k)|赞(0)|评价(0)|浏览(94)

本文整理了Java中java.util.NoSuchElementException.<init>()方法的一些代码示例,展示了NoSuchElementException.<init>()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。NoSuchElementException.<init>()方法的具体详情如下:
包路径:java.util.NoSuchElementException
类名称:NoSuchElementException
方法名:<init>

NoSuchElementException.<init>介绍

[英]Constructs a new NoSuchElementException with the current stack trace filled in.
[中]构造一个新的NoSuchElementException,并填充当前堆栈跟踪。

代码示例

代码示例来源:origin: ReactiveX/RxJava

@Override
  public NoSuchElementException call() throws Exception {
    return new NoSuchElementException();
  }
}

代码示例来源:origin: square/retrofit

private static int indexOf(Object[] array, Object toFind) {
 for (int i = 0; i < array.length; i++) {
  if (toFind.equals(array[i])) return i;
 }
 throw new NoSuchElementException();
}

代码示例来源:origin: google/guava

@Override
 public E next() {
  int index = Integer.numberOfTrailingZeros(remainingSetBits);
  if (index == 32) {
   throw new NoSuchElementException();
  }
  remainingSetBits &= ~(1 << index);
  return elements.get(index);
 }
};

代码示例来源:origin: google/guava

@Override
public T next() {
 if (!iterator.hasNext()) {
  iterator = iterable.iterator();
  if (!iterator.hasNext()) {
   throw new NoSuchElementException();
  }
 }
 return iterator.next();
}

代码示例来源:origin: ReactiveX/RxJava

@Override
  public void onComplete() {
    downstream.onError(new NoSuchElementException());
  }
}

代码示例来源:origin: ReactiveX/RxJava

@Override
public Long next() {
  long c = count;
  if (c != end) {
    count = c + 1;
    return c;
  }
  throw new NoSuchElementException();
}

代码示例来源:origin: square/okhttp

@Override public Snapshot next() {
 if (!hasNext()) throw new NoSuchElementException();
 removeSnapshot = nextSnapshot;
 nextSnapshot = null;
 return removeSnapshot;
}

代码示例来源:origin: square/okhttp

@Override public String next() {
 if (!hasNext()) throw new NoSuchElementException();
 String result = nextUrl;
 nextUrl = null;
 canRemove = true;
 return result;
}

代码示例来源:origin: google/guava

Object getElement() {
  if (element == null) {
   throw new NoSuchElementException();
  } else if (extras == null) {
   return element;
  } else {
   throw multiples(false);
  }
 }
}

代码示例来源:origin: google/guava

@Override
public Entry<K, V> next() {
 if (!hasNext()) {
  throw new NoSuchElementException();
 }
 ValueEntry<K, V> result = nextEntry;
 toRemove = result;
 nextEntry = nextEntry.successorInMultimap;
 return result;
}

代码示例来源:origin: google/guava

@Override
public E first() {
 if (isEmpty()) {
  throw new NoSuchElementException();
 }
 return elements.get(0);
}

代码示例来源:origin: google/guava

@Override
public T next() {
 if (!hasNext()) {
  throw new NoSuchElementException();
 }
 count++;
 return iterator.next();
}

代码示例来源:origin: google/guava

@Override
public T next() {
 if (hasNext()) {
  toRemove = iterator;
  return iterator.next();
 } else {
  throw new NoSuchElementException();
 }
}

代码示例来源:origin: iluwatar/java-design-patterns

/**
 * @return TreeNode next. The next element according to our in-order traversal of the given BST
 * @throws NoSuchElementException if this iterator does not have a next element
 */
@Override
public TreeNode<T> next() throws NoSuchElementException {
 if (pathStack.isEmpty()) {
  throw new NoSuchElementException();
 }
 TreeNode<T> next = pathStack.pop();
 pushPathToNextSmallest(next.getRight());
 return next;
}

代码示例来源:origin: ReactiveX/RxJava

@Override
  public void onComplete() {
    upstream = DisposableHelper.DISPOSED;
    if (defaultValue != null) {
      downstream.onSuccess(defaultValue);
    } else {
      downstream.onError(new NoSuchElementException("The MaybeSource is empty"));
    }
  }
}

代码示例来源:origin: ReactiveX/RxJava

@Override
public T next() {
  if (hasNext()) {
    T v = iteratorNotification.getValue();
    iteratorNotification = null;
    return v;
  }
  throw new NoSuchElementException();
}

代码示例来源:origin: ReactiveX/RxJava

@Override
public T next() {
  if (hasNext()) {
    return queue.poll();
  }
  throw new NoSuchElementException();
}

代码示例来源:origin: ReactiveX/RxJava

@Override
public void onComplete() {
  upstream = SubscriptionHelper.CANCELLED;
  if (!done) {
    done = true;
    T v = defaultValue;
    if (v != null) {
      downstream.onSuccess(v);
    } else {
      downstream.onError(new NoSuchElementException());
    }
  }
}

代码示例来源:origin: ReactiveX/RxJava

@Override
public T next() {
  if (hasNext()) {
    if (iteratorNotification.isOnNext()) {
      T v = iteratorNotification.getValue();
      iteratorNotification = null;
      return v;
    }
  }
  throw new NoSuchElementException();
}

代码示例来源:origin: google/guava

/**
 * Removes and returns the greatest element of this queue.
 *
 * @throws NoSuchElementException if the queue is empty
 */
@CanIgnoreReturnValue
public E removeLast() {
 if (isEmpty()) {
  throw new NoSuchElementException();
 }
 return removeAndGet(getMaxElementIndex());
}

相关文章