本文整理了Java中java.util.List.get()
方法的一些代码示例,展示了List.get()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。List.get()
方法的具体详情如下:
包路径:java.util.List
类名称:List
方法名:get
[英]Returns the element at the specified position in this list.
[中]返回此列表中指定位置的元素。
代码示例来源:origin: spring-projects/spring-framework
private Node getParent() {
if (!this.elements.isEmpty()) {
return this.elements.get(this.elements.size() - 1);
}
else {
return this.node;
}
}
代码示例来源:origin: square/okhttp
/** Returns the remote peer's principle, or null if that peer is anonymous. */
public @Nullable Principal peerPrincipal() {
return !peerCertificates.isEmpty()
? ((X509Certificate) peerCertificates.get(0)).getSubjectX500Principal()
: null;
}
代码示例来源:origin: spring-projects/spring-framework
private static List
List
if (result.isEmpty() || !(result.get(0) instanceof Separator)) {
result.add(0, SEPARATOR);
}
return Collections.unmodifiableList(result);
}
代码示例来源:origin: square/okhttp
private List
int size = list.size();
List
for (int i = 0; i
result.add(s != null ? percentDecode(s, plusIsSpace) : null);
}
return Collections.unmodifiableList(result);
}
代码示例来源:origin: ReactiveX/RxJava
@Test
public void testOverlappingWindows() {
Observable
Observable
List> windows = toLists(windowed);
assertEquals(6, windows.size());
assertEquals(list("zero", "one", "two"), windows.get(0));
assertEquals(list("one", "two", "three"), windows.get(1));
assertEquals(list("two", "three", "four"), windows.get(2));
assertEquals(list("three", "four", "five"), windows.get(3));
assertEquals(list("four", "five"), windows.get(4));
assertEquals(list("five"), windows.get(5));
}
代码示例来源:origin: libgdx/libgdx
private void takeSnapshot () {
mainDependenciesSnapshot.clear();
for (int i = 0; i
}
}
代码示例来源:origin: square/okhttp
static String extractStatusLine(Map
throws ProtocolException {
List
if (values == null || values.size() == 0) {
// The status line is missing. This suggests a badly behaving cache.
throw new ProtocolException(
"CacheResponse is missing a \'null\' header containing the status line. Headers="
+ javaResponseHeaders);
}
return values.get(0);
}
代码示例来源:origin: ReactiveX/RxJava
@Test
public void testToFutureList() throws InterruptedException, ExecutionException {
Flowable
Future> f = obs.toList().toFuture();
assertEquals("one", f.get().get(0));
assertEquals("two", f.get().get(1));
assertEquals("three", f.get().get(2));
}
代码示例来源:origin: square/okhttp
public static List
List
for (int i = 0, size = protocols.size(); i
if (protocol == Protocol.HTTP_1_0) continue; // No HTTP/1.0 for ALPN.
names.add(protocol.toString());
}
return names;
}
代码示例来源:origin: ReactiveX/RxJava
@Test
public void testOverlappingWindows() {
Flowable
Flowable
List> windows = toLists(windowed);
assertEquals(6, windows.size());
assertEquals(list("zero", "one", "two"), windows.get(0));
assertEquals(list("one", "two", "three"), windows.get(1));
assertEquals(list("two", "three", "four"), windows.get(2));
assertEquals(list("three", "four", "five"), windows.get(3));
assertEquals(list("four", "five"), windows.get(4));
assertEquals(list("five"), windows.get(5));
}
代码示例来源:origin: square/okhttp
private void removeAllCanonicalQueryParameters(String canonicalName) {
for (int i = encodedQueryNamesAndValues.size() - 2; i >= 0; i -= 2) {
if (canonicalName.equals(encodedQueryNamesAndValues.get(i))) {
encodedQueryNamesAndValues.remove(i + 1);
encodedQueryNamesAndValues.remove(i);
if (encodedQueryNamesAndValues.isEmpty()) {
encodedQueryNamesAndValues = null;
return;
}
}
}
}
代码示例来源:origin: spring-projects/spring-framework
@Override
public ResponseSpec onStatus(Predicate
Function
if (this.statusHandlers.size() == 1 && this.statusHandlers.get(0) == DEFAULT_STATUS_HANDLER) {
this.statusHandlers.clear();
}
this.statusHandlers.add(new StatusHandler(statusPredicate,
(clientResponse, request) -> exceptionFunction.apply(clientResponse)));
return this;
}
代码示例来源:origin: spring-projects/spring-framework
protected List
if (this.hasVersionResolver && !this.hasCssLinkTransformer) {
List
boolean hasTransformers = !this.transformers.isEmpty();
boolean hasCaching = hasTransformers && this.transformers.get(0) instanceof CachingResourceTransformer;
result.add(hasCaching ? 1 : 0, new CssLinkResourceTransformer());
return result;
}
return this.transformers;
}
代码示例来源:origin: greenrobot/EventBus
/** Only updates subscriptionsByEventType, not typesBySubscriber! Caller must update typesBySubscriber. */
private void unsubscribeByEventType(Object subscriber, Class> eventType) {
List
if (subscriptions != null) {
int size = subscriptions.size();
for (int i = 0; i
if (subscription.subscriber == subscriber) {
subscription.active = false;
subscriptions.remove(i);
i--;
size--;
}
}
}
}
代码示例来源:origin: square/okhttp
/** Returns the first header named {@code name}, or null if no such header exists. */
public String getHeader(String name) {
List
return values.isEmpty() ? null : values.get(0);
}
代码示例来源:origin: spring-projects/spring-framework
@Override
public CacheInvocationParameter[] getAllParameters(Object... values) {
if (this.allParameterDetails.size() != values.length) {
throw new IllegalStateException("Values mismatch, operation has " +
this.allParameterDetails.size() + " parameter(s) but got " + values.length + " value(s)");
}
List
for (int i = 0; i
}
return result.toArray(new CacheInvocationParameter[0]);
}
代码示例来源:origin: ReactiveX/RxJava
@Test
public void testNonOverlappingWindows() {
Observable
Observable
List> windows = toLists(windowed);
assertEquals(2, windows.size());
assertEquals(list("one", "two", "three"), windows.get(0));
assertEquals(list("four", "five"), windows.get(1));
}
代码示例来源:origin: bumptech/glide
private static boolean memoizeStaticMethodFromArguments(ExecutableElement staticMethod) {
return staticMethod.getParameters().isEmpty()
|| (staticMethod.getParameters().size() == 1
&& staticMethod.getParameters().get(0).getSimpleName().toString()
.equals("android.content.Context"));
}
代码示例来源:origin: libgdx/libgdx
private void restore () {
mainDependencies.clear();
((ExtensionTableModel)table.getModel()).unselectAll();
for (int i = 0; i
String extensiOnName= mainDependenciesSnapshot.get(i).getName();
if (((ExtensionTableModel)table.getModel()).hasExtension(extensionName)) {
((ExtensionTableModel)table.getModel()).setSelected(extensionName, true);
} else {
}
}
}
代码示例来源:origin: spring-projects/spring-framework
protected List
if (this.hasVersionResolver && !this.hasCssLinkTransformer) {
List
boolean hasTransformers = !this.transformers.isEmpty();
boolean hasCaching = hasTransformers && this.transformers.get(0) instanceof CachingResourceTransformer;
result.add(hasCaching ? 1 : 0, new CssLinkResourceTransformer());
return result;
}
return this.transformers;
}