热门标签 | 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;
}

推荐阅读
  • 本文详细介绍了Java反射机制的基本概念、获取Class对象的方法、反射的主要功能及其在实际开发中的应用。通过具体示例,帮助读者更好地理解和使用Java反射。 ... [详细]
  • WinMain 函数详解及示例
    本文详细介绍了 WinMain 函数的参数及其用途,并提供了一个具体的示例代码来解析 WinMain 函数的实现。 ... [详细]
  • 如果应用程序经常播放密集、急促而又短暂的音效(如游戏音效)那么使用MediaPlayer显得有些不太适合了。因为MediaPlayer存在如下缺点:1)延时时间较长,且资源占用率高 ... [详细]
  • 基于iSCSI的SQL Server 2012群集测试(一)SQL群集安装
    一、测试需求介绍与准备公司计划服务器迁移过程计划同时上线SQLServer2012,引入SQLServer2012群集提高高可用性,需要对SQLServ ... [详细]
  • Spring – Bean Life Cycle
    Spring – Bean Life Cycle ... [详细]
  • Halcon之图像梯度、图像边缘、USM锐化
    图像梯度、图像边缘、USM锐化图像梯度、图像边缘、USM锐化图像梯度、图像边缘、USM锐化图像卷积:1.模糊2.梯度3.边缘4.锐化1.视频教程:B站、 ... [详细]
  • [转]doc,ppt,xls文件格式转PDF格式http:blog.csdn.netlee353086articledetails7920355确实好用。需要注意的是#import ... [详细]
  • window下的python安装插件,Go语言社区,Golang程序员人脉社 ... [详细]
  • 本文详细介绍了 PHP 中对象的生命周期、内存管理和魔术方法的使用,包括对象的自动销毁、析构函数的作用以及各种魔术方法的具体应用场景。 ... [详细]
  • Spring Data JdbcTemplate 入门指南
    本文将介绍如何使用 Spring JdbcTemplate 进行数据库操作,包括查询和插入数据。我们将通过一个学生表的示例来演示具体步骤。 ... [详细]
  • 我有一个从C项目编译的.o文件,该文件引用了名为init_static_pool ... [详细]
  • 本文介绍了如何在 Spring 3.0.5 中使用 JdbcTemplate 插入数据并获取 MySQL 表中的自增主键。 ... [详细]
  • 在 CentOS 6.4 上安装 QT5 并启动 Qt Creator 时,可能会遇到缺少 GLIBCXX_3.4.15 的问题。这是由于系统中的 libstdc++.so.6 版本过低。本文将详细介绍如何通过更新 GCC 版本来解决这一问题。 ... [详细]
  • [c++基础]STL
    cppfig15_10.cppincludeincludeusingnamespacestd;templatevoidprintVector(constvector&integer ... [详细]
  • 在多线程并发环境中,普通变量的操作往往是线程不安全的。本文通过一个简单的例子,展示了如何使用 AtomicInteger 类及其核心的 CAS 无锁算法来保证线程安全。 ... [详细]
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社区 版权所有