热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

java.util.List.get()方法的使用及代码示例

本文整理了Java中java.util.List.get()方法的一些代码示例,展示了List.get()的具体用法。这些代码示例主要来源于

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

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 prependWithSeparator(List elements) {
List result = new ArrayList<>(elements);
if (result.isEmpty() || !(result.get(0) instanceof Separator)) {
result.add(0, SEPARATOR);
}
return Collections.unmodifiableList(result);
}

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

private List percentDecode(List list, boolean plusIsSpace) {
int size = list.size();
List result = new ArrayList<>(size);
for (int i = 0; i String s = list.get(i);
result.add(s != null ? percentDecode(s, plusIsSpace) : null);
}
return Collections.unmodifiableList(result);
}

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

@Test
public void testOverlappingWindows() {
Observable subject = Observable.fromArray(new String[] { "zero", "one", "two", "three", "four", "five" });
Observable> windowed = subject.window(3, 1);
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 mainDependenciesSnapshot.add(mainDependencies.get(i));
}
}

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

static String extractStatusLine(Map> javaResponseHeaders)
throws ProtocolException {
List values = javaResponseHeaders.get(null);
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 obs = Flowable.just("one", "two", "three");
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 alpnProtocolNames(List protocols) {
List names = new ArrayList<>(protocols.size());
for (int i = 0, size = protocols.size(); i Protocol protocol = protocols.get(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 subject = Flowable.fromArray(new String[] { "zero", "one", "two", "three", "four", "five" });
Flowable> windowed = subject.window(3, 1);
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 statusPredicate,
Function> exceptionFunction) {
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 getResourceTransformers() {
if (this.hasVersionResolver && !this.hasCssLinkTransformer) {
List result = new ArrayList<>(this.transformers);
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 subscriptiOns= subscriptionsByEventType.get(eventType);
if (subscriptions != null) {
int size = subscriptions.size();
for (int i = 0; i Subscription subscription = subscriptions.get(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 values = headers.values(name);
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 result = new ArrayList<>();
for (int i = 0; i result.add(this.allParameterDetails.get(i).toCacheInvocationParameter(values[i]));
}
return result.toArray(new CacheInvocationParameter[0]);
}

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

@Test
public void testNonOverlappingWindows() {
Observable subject = Observable.just("one", "two", "three", "four", "five");
Observable> windowed = subject.window(3);
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 mainDependencies.add(mainDependenciesSnapshot.get(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 getResourceTransformers() {
if (this.hasVersionResolver && !this.hasCssLinkTransformer) {
List result = new ArrayList<>(this.transformers);
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;
}

推荐阅读
  • Explore a common issue encountered when implementing an OAuth 1.0a API, specifically the inability to encode null objects and how to resolve it. ... [详细]
  • 本文详细介绍了Java中org.neo4j.helpers.collection.Iterators.single()方法的功能、使用场景及代码示例,帮助开发者更好地理解和应用该方法。 ... [详细]
  • 1:有如下一段程序:packagea.b.c;publicclassTest{privatestaticinti0;publicintgetNext(){return ... [详细]
  • 本文介绍了Java并发库中的阻塞队列(BlockingQueue)及其典型应用场景。通过具体实例,展示了如何利用LinkedBlockingQueue实现线程间高效、安全的数据传递,并结合线程池和原子类优化性能。 ... [详细]
  • 数据库内核开发入门 | 搭建研发环境的初步指南
    本课程将带你从零开始,逐步掌握数据库内核开发的基础知识和实践技能,重点介绍如何搭建OceanBase的开发环境。 ... [详细]
  • 使用 Azure Service Principal 和 Microsoft Graph API 获取 AAD 用户列表
    本文介绍了一段通用代码示例,该代码不仅能够操作 Azure Active Directory (AAD),还可以通过 Azure Service Principal 的授权访问和管理 Azure 订阅资源。Azure 的架构可以分为两个层级:AAD 和 Subscription。 ... [详细]
  • 深入解析Spring Cloud Ribbon负载均衡机制
    本文详细介绍了Spring Cloud中的Ribbon组件如何实现服务调用的负载均衡。通过分析其工作原理、源码结构及配置方式,帮助读者理解Ribbon在分布式系统中的重要作用。 ... [详细]
  • XNA 3.0 游戏编程:从 XML 文件加载数据
    本文介绍如何在 XNA 3.0 游戏项目中从 XML 文件加载数据。我们将探讨如何将 XML 数据序列化为二进制文件,并通过内容管道加载到游戏中。此外,还会涉及自定义类型读取器和写入器的实现。 ... [详细]
  • UNP 第9章:主机名与地址转换
    本章探讨了用于在主机名和数值地址之间进行转换的函数,如gethostbyname和gethostbyaddr。此外,还介绍了getservbyname和getservbyport函数,用于在服务器名和端口号之间进行转换。 ... [详细]
  • 深入解析Android自定义View面试题
    本文探讨了Android Launcher开发中自定义View的重要性,并通过一道经典的面试题,帮助开发者更好地理解自定义View的实现细节。文章不仅涵盖了基础知识,还提供了实际操作建议。 ... [详细]
  • 本文详细记录了在基于Debian的Deepin 20操作系统上安装MySQL 5.7的具体步骤,包括软件包的选择、依赖项的处理及远程访问权限的配置。 ... [详细]
  • 本文将介绍如何编写一些有趣的VBScript脚本,这些脚本可以在朋友之间进行无害的恶作剧。通过简单的代码示例,帮助您了解VBScript的基本语法和功能。 ... [详细]
  • 本文详细介绍了Akka中的BackoffSupervisor机制,探讨其在处理持久化失败和Actor重启时的应用。通过具体示例,展示了如何配置和使用BackoffSupervisor以实现更细粒度的异常处理。 ... [详细]
  • 本文详细介绍了Java编程语言中的核心概念和常见面试问题,包括集合类、数据结构、线程处理、Java虚拟机(JVM)、HTTP协议以及Git操作等方面的内容。通过深入分析每个主题,帮助读者更好地理解Java的关键特性和最佳实践。 ... [详细]
  • RecyclerView初步学习(一)
    RecyclerView初步学习(一)ReCyclerView提供了一种插件式的编程模式,除了提供ViewHolder缓存模式,还可以自定义动画,分割符,布局样式,相比于传统的ListVi ... [详细]
author-avatar
kkq--_771
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有