Java LinkedList boolean addAll(int index,Collection c)方法,带有示例

LinkedList boolean addAll(int index,Collection c)方法 (LinkedList boolean addAll(int index, Collection c) method)

  • This method is available in package java.util.Collection and here, Collection is an interface.

    该方法在java.util.Collection包中可用,在这里, Collection是一个接口。

  • In this method, the index is the position where we have to start inserting the Collection elements and Collection is the list of elements whether Collection is of ArrayList, LinkedList type, etc.

    在此方法中,索引是我们必须开始插入Collection元素的位置,而Collection是元素列表,无论Collection是ArrayList,LinkedList类型还是其他类型。

  • This method is used to insert the collection of objects at the specified position in the linked list.

    此方法用于在链接列表的指定位置插入对象的集合。

  • Index position starts from 0.

    索引位置从0开始。

Syntax:

句法:

    boolean addAll(int index , Collection c){
}

Parameter(s):

参数:

We can pass two arguments as a parameter in the method and the Collection parameter is the collection of elements will add from the starting position of the specified index in the linked list.

我们可以在方法中传递两个参数作为参数,而Collection参数是将从链表中指定索引的起始位置开始添加的元素集合。

Return value:

返回值:

The return type of this method is boolean that means this method returns true during execution of at least inserting of one element.

该方法的返回类型为布尔值 ,这意味着该方法在至少插入一个元素的过程中返回true。

Java程序演示LinkedList addAll(int index,Collection c)方法的示例 (Java program to demonstrate example of LinkedList addAll(int index, Collection c) method)

import java.util.LinkedList;
import java.util.ArrayList;
public class LinkList {
public static void main(String args[]) {
// Creating a LinkedList 
LinkedList list = new LinkedList();
// Use add() method to add objects 
// in the LinkedList
list.add("J");
list.add("A");
list.add("V");
list.add("A");
// Creating a Collection ArrayList object 
// of ArrayList Type
ArrayList al = new ArrayList();
al.add("P");
al.add("R");
al.add("O");
al.add("G");
al.add("R");
al.add("A");
al.add("M");
al.add("M");
al.add("I");
al.add("N");
al.add("G");
// Displaying the Current LinkedList 
System.out.println("The Current LinkedList is: " + list);
// Appending the collection ArrayList to the 
// LinkedList and ArrayList will start inserting 
// from index 4(i.e. From Fifth Position )
list.addAll(4, al);
//  Displaying the new LinkedList
System.out.println("The new linked list is: " + list);
}
}

Output

输出量

D:\Programs>javac LinkList.java
D:\Programs>java LinkList
The Current LinkedList is: [J, A, V, A]
The new linked list is: [J, A, V, A, P, R, O, G, R, A, M, M, I, N, G]

翻译自: https://www.includehelp.com/java/linkedlist-boolean-addall-int-index-collection-c-method-with-example.aspx

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

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

相关文章

高质量SQL的30条建议!(后端必备)

这是我的第 191 期分享作者 | 捡田螺的小男孩来源 | 捡田螺的小男孩(ID:gh_873ad5979a0b) 分享 | Java中文社群(ID:javacn666)本文将结合实例demo,阐述30条有关于优化SQL的建议,多数…

滤波电容的选择(调试中)

整个系统高电平时12V,信号是ms级的负脉冲,脉冲的下降沿很陡,当用示波器展开看的时候,发现了低于0V的过冲,能低到-6V(相当严重),这是在整个箱子的出口处测量到的。在主控板&#xff0…

sicp

sicp (structure and interpretion of computer programs ,编号为6.001 )是麻省理工学院的一门经典计算机入门课程,虽然近年被另外一门课程所取代(6.00 或6.01 ),但最近好像有复活 的迹象。Perter Norvig 写了关于sicp…

Redis的自白:我为什么在单线程的这条路上越走越远?

这是我的第 192 期分享作者 | 王磊来源 | Java中文社群(ID:javacn666)转载请联系授权(微信ID:GG_Stone)我是 Redis,今年 11 岁了~曾几何时我是辣么的单纯,辣么的可爱,而如…

两个矩阵相乘的乘法次数_C ++程序将两个数字相乘而不使用乘法运算符

两个矩阵相乘的乘法次数The problem is we have two integer numbers and find the multiplication of them without using the multiplication operator. This problem can be solved using the Russian peasant algorithm. Assume the two given numbers are m and n. Initia…

关于引用

2019独角兽企业重金招聘Python工程师标准>>> 1、 <!-- lang: html --> <!DOCTYPE HTML> <!-- lang: html --> <html> <!-- lang: html --> <head> <!-- lang: html --> <meta charset"utf-8" /> <!--…

ruby array_在Ruby中使用Array.delete()和Array.delete_at()从Array中移除元素

ruby arrayRuby Array.delete()和Array.delete_at()方法 (Ruby Array.delete() and Array.delete_at() methods) In the last article, we have seen how we can remove the elements from an instance of Array class with the help of Array.pop() and Array.shift()? 在上一…

一口气说出 6 种延时队列的实现方法,面试官满意的笑了

这是我的第 193 期分享作者 | 程序员内点事来源 | 程序员内点事&#xff08;ID&#xff1a;chegnxy-nds&#xff09; 分享 | Java中文社群&#xff08;ID&#xff1a;javacn666&#xff09;五一期间原计划是写两篇文章&#xff0c;看一本技术类书籍&#xff0c;结果这五天由于自…

一些c语言图形库

想编程绘制一些简单的图形&#xff0c;有不少的图形库可以选择&#xff1a; &#xff08;1&#xff09;BGI图形库&#xff1a;即turbo c所带的图形库。misaki 在vc&#xff08;vc6,vc2008,vc2010等)下重写了该库&#xff0c;名为EGE 。另一个类似的vc(vc6,vc2008,vc2010)下的库…

acl 服务器编程框架特点介绍

2019独角兽企业重金招聘Python工程师标准>>> acl 中服务器框架模块是一个非常重要的模块&#xff0c;使用该模块技术人员可以快速地写出稳定、安全、高效的网络服务应用&#xff0c;该模块主要来源于著名的邮件服务器程序 (Postfix) 中的 master 模块&#xff0c;为…

turbo c相关文档

无意中在网上找到的turbo c 2.0相关文档&#xff0c;有reference guide 和user guide.下载地址见&#xff08;镜像一 &#xff0c;镜像二 &#xff0c;镜像三 &#xff0c;镜像四 &#xff09;。这些网站还有很多其他各类软件相关文档&#xff0c;感兴趣的可以自己看看。另外&a…

一个类可以有一个接口,接口可以有一个Java类吗?

In the very first step, we will see can a class have an interface in Java? 在第一步中&#xff0c;我们将看到类可以在Java中具有接口吗&#xff1f; Yes, it is possible to define an interface inside the class. 是的&#xff0c;可以在类内部定义接口。 The interf…

人人都能看懂的 6 种限流实现方案!(纯干货)

这是我的第 195 期分享作者 | 王磊来源 | Java中文社群&#xff08;ID&#xff1a;javacn666&#xff09;转载请联系授权&#xff08;微信ID&#xff1a;GG_Stone&#xff09;为了上班方便&#xff0c;去年我把自己在北郊的房子租出去了&#xff0c;搬到了南郊&#xff0c;这样…

測试新浪微博@小冰 为代码机器人的一些方法

微软的微信小冰被腾讯封杀之后,如今移民到了新浪微博; 小冰 这里贴一些眼下有效的用来识别是这是"机器"而不是有正常人类智商的代码的方法: 1. 在正常的文字中夹杂其他符号,确保不存在有意义的连续的词汇,人眼能够分辨,机器不知所云而会露馅: 比方: ^^^小v冰^^^-…

nethack

nethack是一款开源游戏&#xff0c;不支持声音和华丽的图像&#xff0c;却被称为最好玩的游戏之一。 相关链接&#xff1a; nethack主页 nethack下载地址 nethack wiki nethack贴吧 beginners guide to nethack sources 其他一些有趣的链接&#xff1a; games in c with s…

秒建一个后台管理系统?用这5个开源免费的Java项目就够了

这是我的第 196 期分享作者 | Guide来源 | JavaGuide&#xff08;ID&#xff1a;JavaGuide&#xff09; 分享 | Java中文社群&#xff08;ID&#xff1a;javacn666&#xff09;大家好&#xff0c;我是 Guide 哥&#xff0c;一个三观比主角还正的技术人。今天推荐几个 Java 项目…

读《白帽子讲Web安全》之客户端脚本安全(一)

2019独角兽企业重金招聘Python工程师标准>>> 【第2章 浏览器安全】 1、同源策略&#xff08;Same Origin Policy&#xff09;是一种约定&#xff0c;它是浏览器最核心也最基本的安全功能。 浏览器的同源策略&#xff0c;限制了来自不同源的“document”或脚本&…

RocketMQ一行代码造成消息发送失败

这是我的第 198 期分享作者 | 丁威来源 | 中间件兴趣圈&#xff08;ID&#xff1a;dingwpmz_zjj&#xff09;分享 | Java中文社群&#xff08;ID&#xff1a;javacn666&#xff09;1、问题现象首先接到项目反馈使用 RocketMQ 会出现如下错误&#xff1a;错误信息关键点&#xf…

生命游戏(game of life)

生命游戏 &#xff08;game of life )是一款非常著名的游戏。它包括一个二维 矩形世界&#xff0c;这个世界中的每个方格居住着一个活着的或死了的细胞。一个细胞在下一个时刻生死取决于相邻八个方格中活着的或死了的细胞的数量。如果相邻方格活着的细胞数量过多&#xff0c;这…

setpriority_Java Thread类的最终void setPriority(int priority)方法(带示例)

setpriority线程类最终void setPriority(int priority) (Thread Class final void setPriority(int priority)) This method is available in package java.lang.Thread.setPriority(int priority). 软件包java.lang.Thread.setPriority(int priority)中提供了此方法。 This me…