Java LinkedList对象的get(int index)方法与示例

LinkedList对象的get(int索引)方法 (LinkedList Object get(int index) method)

  • This method is available in package java.util.LinkedList.get(int index).

    软件包java.util.LinkedList.get(int index)中提供了此方法。

  • This method is used to retrieve an object or element at the specified position of the linked list.

    此方法用于在链接列表的指定位置检索对象或元素。

Syntax:

句法:

    Object get(int index){
}

Parameter(s):

参数:

We pass only one object as a parameter in the method of the linked list and the parameter is the position of the returned element.

在链接列表的方法中,我们仅传递一个对象作为参数,并且该参数是返回元素的位置。

Return value:

返回值:

The return type of this method is Object that means this method returns an element at the specified position of the linked list.

该方法的返回类型为Object ,这意味着该方法在链接列表的指定位置返回一个元素。

Java程序演示LinkedList get()方法的示例 (Java program to demonstrate example of LinkedList get() method)

import java.util.LinkedList;
public class LinkList {
public static void main(String[] args) {
LinkedList list = new LinkedList();
// add() method to add elements in the list 
list.add(10);
list.add(20);
list.add(30);
list.add(40);
list.add(50);
//  Current list Output
System.out.println("The Current list is:" + list);
//  Retrieve an element by using get(int index) method
System.out.println("The indexed element of the linked list is:" + list.get(2));
//  New List Output
System.out.println("The new list is:" + list);
}
}

Output

输出量

D:\Programs>javac LinkList.java
D:\Programs>java LinkList
The Current list is:[10, 20, 30, 40, 50]
The indexed element of the linked list is:30
The new list is:[10, 20, 30, 40, 50]

翻译自: https://www.includehelp.com/java/linkedlist-object-get-int-index--method-with-example.aspx

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/380097.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

Sql养成一个好习惯是一笔财富

我们做软件开发的,大部分人都离不开跟数据库打交道,特别是erp开发的,跟数据库打交道更是频繁,存储过程动不动就是上千行,如果数据量大,人员流动大,那么我么还能保证下一段时间系统还能流畅的运行…

java上传类

publicString doFormFile(FormFile file, String dir) { try { File f new File(dir); if (!f.exists()) { f.mkdir();//如果路径不存在,创建 } InputStream in file.getInputStream(); …

C——用冒泡排序法、选择排序法对随机输入的10个整数从小到大排序

//冒泡排序法 #include <stdio.h> int main() {int i,j,t,a[10];for(i0;i<10;i){scanf("%d",&a[i]);}for(i0;i<9;i)//10个数&#xff0c;进行9次循环&#xff0c;进行9趟比较{for(j0;j<9-i;j)//在每一趟比较中&#xff0c;进行9-i次比较{if(a[j]&…

远控免杀专题(21)-HERCULES免杀

转载&#xff1a;https://mp.weixin.qq.com/s/Rkr9lixzL4tiL89r10ndig 免杀能力一览表 几点说明&#xff1a; 1、上表中标识 √ 说明相应杀毒软件未检测出病毒&#xff0c;也就是代表了Bypass。 2、为了更好的对比效果&#xff0c;大部分测试payload均使用msf的windows/mete…

PHP Cookbook读书笔记 – 第16章互联网服务

发送电子邮件 书中主要是以PEAR中的邮件发送类&#xff08;Mail&#xff09;来讲解的&#xff08;关于如何在WIN系统下安装PEAR可以参考WIN下成功安装PEAR&#xff09;。PEAR的MAIL类可以通过3种方式来发送电子邮件&#xff1a; 通过PHP内部的mail函数来发送 通过sendmail程序来…

Python | 使用matplotlib.pyplot创建条形图

Problem statement: Using matplotlib.pyplot library in python draw a bar graph with two values for comparison, using different colors. 问题陈述&#xff1a;在python中使用matplotlib.pyplot库使用不同的颜色绘制带有两个值的条形图以进行比较。 Program: 程序&#…

SQLSERVER内核架构剖析

我们做管理软件的&#xff0c;主要核心就在数据存储管理上。所以数据库设计是我们的重中之重。为了让我们的管理软件能够稳定、可扩展、性能优秀、可跟踪排错、可升级部署、可插件运行&#xff0c;我们往往研发自己的管理软件开发平台。我们总是希望去学习别人的开发平台&#…

输出以下的杨辉三角形(要求输入个数字,表示需要输出几行)

#include<stdio.h> int main() {int i,j,k,n,x,a[100][100];a[0][1]1;scanf("%d",&x);for(i1;i<x;i){for(j1;j<i;j){a[i][j]a[i-1][j-1]a[i-1][j];printf("%5d ",a[i][j]);//%5d 表示右对齐隔5个空格&#xff1b;}//同理&#xff0c;%-5d…

远控免杀专题(22)-SpookFlare免杀

转载&#xff1a;https://mp.weixin.qq.com/s/LfuQ2XuD7YHUWJqMRUmNVA 免杀能力一览表 几点说明&#xff1a; 1、上表中标识 √ 说明相应杀毒软件未检测出病毒&#xff0c;也就是代表了Bypass。 2、为了更好的对比效果&#xff0c;大部分测试payload均使用msf的windows/mete…

二维动态数组定义及二维静态数组与**P的区别

矩力集成2008年校园招聘笔试题&#xff1a;动态申请一个二维数组存储图像阵列 传统的解决方案是分配一个指针数组, 然后把每个指针初始化为动态分配的 列"。 以下为一个二维的例子: //typedef int (*arraypoiter)[ncolumns]; int **dynamic_alloc_arrays(unsigned int nro…

置换元素和非置换元素_循环置换数组元素的C程序

置换元素和非置换元素Problem statement: Write a c program to cyclically permute the element of an array. (In right to left direction). Array should be taken as input from the user. 问题陈述&#xff1a;编写一个c程序来循环置换array的元素 。 (从右到左方向)。 数…

最新Asp.net源码推荐列表(4月7日)

好久没有在cnblogs给大家发布asp.net源码了&#xff0c;把最近整理的一些发给大家&#xff0c;希望对大家有所帮助&#xff0c;以后争取保持每周发布&#xff01;- WOBIZ第一季1.2版源码 Hits:29 2008-4-7 [结构图] [^][VS2005Access] 电子商务2.0软件是窝窝团队基于对互联网…

远控免杀专题(23)-SharpShooter免杀

转载&#xff1a;https://mp.weixin.qq.com/s/EyvGfWXLbxkHe7liaNFhGg 免杀能力一览表 几点说明&#xff1a; 1、上表中标识 √ 说明相应杀毒软件未检测出病毒&#xff0c;也就是代表了Bypass。 2、为了更好的对比效果&#xff0c;大部分测试payload均使用msf的windows/mete…

MySQL 发展史

一.MySQL 标志说明MySQL的海豚标志的名字叫“sakila”&#xff0c;它是由MySQL AB的创始人从用户在“海豚命名”的竞赛中建议的大量的名字表中选出的。获胜的名字是由来自非洲斯威士兰的开源软件开发者Ambrose Twebaze提供。根据Ambrose所说&#xff0c;Sakila来自一种叫SiSwat…

scanf读取字符_在C语言中使用scanf()读取整数时跳过字符

scanf读取字符Let suppose, we want to read time in HH:MM:SS format and store in the variables hours, minutes and seconds, in that case we need to skip columns (:) from the input values. 假设&#xff0c;我们要读取HH&#xff1a;MM&#xff1a;SS格式的时间 &…

An Algorithm Summary of Programming Collective Intelligence (3)

k-Nearest Neighbors kNN(不要问我叫什么)PCI里面用kNN做了一个价格预测模型&#xff0c;还有一个简单的电影喜好预测。简单来说就是要对一个东西做数值预测&#xff0c;就要先有一堆已经有数值的东西&#xff0c;从里面找出和要预测的东西相似的&#xff0c;再通过计算这些相似…

远控免杀专题(24)-CACTUSTORCH免杀

转载&#xff1a;https://mp.weixin.qq.com/s/g0CYvFMsrV7bHIfTnSUJBw 免杀能力一览表 几点说明&#xff1a; 1、上表中标识 √ 说明相应杀毒软件未检测出病毒&#xff0c;也就是代表了Bypass。 2、为了更好的对比效果&#xff0c;大部分测试payload均使用msf的windows/mete…

DOM快捷键

DOM所有的命令(CMD) 步骤/方法 cmd命令大全&#xff08;第一部分&#xff09;winver---------检查Windows版本 wmimgmt.msc----打开windows管理体系结构(WMI) wupdmgr--------windows更新程序 wscript--------windows脚本宿主设置 write----------写字板 winmsd---------系统…

病毒的手工排除与分析(更新完毕)

作者简介杨京涛    8年以上的IT行业经验&#xff0c;理解企业需求&#xff0c;有企业ERP软件部署规划能力&#xff0c;有综合布线网络规划和管理能力。熟悉软件以及各类硬件&#xff0c;电话程控设备&#xff0c;各类网络设备的管理维护。有编程基础,熟悉VBA、脚本、批处理…

JavaScript中的String substring()方法和示例

JavaScript | 字符串substring()方法 (JavaScript | String substring() Method) The String.substring() method in JavaScript is used to return a part of the string. The substring() extracted is from the given start and end index of the string. JavaScript中的Str…