Java ArrayList removeRange()方法與示例

ArrayList類removeRange()方法 (ArrayList Class removeRange() method)

  • removeRange() method is available in java.util package.

    removeRange()方法在java.util包中可用。

  • removeRange() method is used to remove the elements whose range is between st_in(start index) and en_in(end index) of this Arraylist. Here, st_in(inclusive) & en_in(exclusive).

    removeRange()方法用于刪除范圍在此Arraylist的st_in(開始索引)和en_in(結束索引)之間的元素。 在這里, st_in(含)和en_in(不含) 。

  • removeRange() method is a non-static method so it is accessible with the class object and if we try to access the method with the class name then we will get an error.

    removeRange()方法是一種非靜態方法,因此可以通過類對象進行訪問,如果嘗試使用類名稱訪問該方法,則會收到錯誤消息。

  • removeRange() method may throw an exception at the time of removing elements within the given range.

    removeRange()方法在刪除給定范圍內的元素時可能會引發異常。

    IndexOutOfBoundsException: This exception may throw when the given range does not exist.

    IndexOutOfBoundsException :如果給定范圍不存在,則可能引發此異常。

Syntax:

句法:

    public void removeRange(int st_in, int end_in);

Parameter(s):

參數:

  • int st_in – represent the index of starting element to remove.

    int st_in –表示要刪除的起始元素的索引。

  • int en_in – represents the index of ending element to remove.

    int en_in –表示要刪除的結束元素的索引。

Return value:

返回值:

The return type of this method is void, it returns nothing.

此方法的返回類型為void ,不返回任何內容。

Example:

例:

// Java program to demonstrate the example 
// of void removeRange() method of ArrayList
import java.util.*;
public class RemoveRangeOfArrayList extends ArrayList {
public static void main(String[] args) {
// Create an ArrayList with initial 
// capacity of storing elements
RemoveRangeOfArrayList arr_l = new RemoveRangeOfArrayList();
// By using add() method is to add 
// elements in this ArrayList
arr_l.add("C");
arr_l.add("C++");
arr_l.add("JAVA");
arr_l.add("DOTNET");
arr_l.add("PHP");
// Display ArrayList
System.out.println("ArrayList Elements :" + arr_l);
// By using removeRange() method is to remove the 
// element at index 2 and 3 like JAVA , DOTNET
arr_l.removeRange(2, 4);
// Display ArrayList 
System.out.println("arr_l.removeRange(2,4) : " + arr_l);
}
}

Output

輸出量

ArrayList Elements :[C, C++, JAVA, DOTNET, PHP]
arr_l.removeRange(2,4) : [C, C++, PHP]

翻譯自: https://www.includehelp.com/java/arraylist-removerange-method-with-example.aspx

本文來自互聯網用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務,不擁有所有權,不承擔相關法律責任。
如若轉載,請注明出處:http://www.pswp.cn/news/541649.shtml
繁體地址,請注明出處:http://hk.pswp.cn/news/541649.shtml
英文地址,請注明出處:http://en.pswp.cn/news/541649.shtml

如若內容造成侵權/違法違規/事實不符,請聯系多彩編程網進行投訴反饋email:809451989@qq.com,一經查實,立即刪除!

相關文章

Spring注釋事務失效及解決辦法

如果帶上事務&#xff0c;那么用annotation方式的事務注解和bean配置&#xff0c;事務會失效&#xff0c;要將service bean配置到xml文件中才行 在主容器中&#xff08;applicationContext.xml&#xff09;&#xff0c;將Controller的注解排除掉 <context:component-scan …

html5畫分形圖形,2.5 繪制透明圖形 - HTML5 Canvas 實戰

對于需要圖形分層的應用&#xff0c;經常需要處理透明度。本節&#xff0c;我們將學習如何使用全局透明度設置圖形的透明度。圖2-5 繪制透明圖形繪制步驟按照以下步驟&#xff0c;在一個不透明的矩形之上&#xff0c;繪制一個透明的圓&#xff1a;1. 定義2D畫布上下文&#xff…

計算機網絡子網劃分_子網劃分和超網| 計算機網絡

計算機網絡子網劃分1)子網劃分 (1) Subnetting) Subnetting is a concept of diving a block of addresses into sub-blocks of addresses. During the era of classful addressing (as it’s obscured now), subnetting was introduced. Say, an organization is granted a la…

html5錄音功能代碼,recorder.js 基于 HTML5 實現錄音功能

recorder.js 基于 HTML5 實現錄音功能2020-06-23 01:49:56recorder.jsmicrophone基于HTML5的錄音功能&#xff0c;輸出格式為mp3文件。前言完全依賴H5原生API所涉及的API&#xff1a;WebRTC、AudioContext、Worker、Video/Audio API、Blob、URL兼容性Chrome、FF、Edge、QQ、360…

data.frame類型數據如何將第一列值替換為行號

data.frame類型數據如何將第一列值替換為行號 row.names(data) <- data[, 1]data <- data[, -1]

html5頁面引入jquery,如何在javascript中引入jQuery?

jquery是一個用來代替JavaScript來快捷書寫前端腳本語言的庫&#xff0c;jquery可以大大的簡化復雜的js代碼&#xff0c;使開發人員專注于實現頁面的效果。jquery的導入方式有兩種&#xff0c;一種是本地導入&#xff0c;一種是從超鏈接導入。方式一&#xff1a;本地導入我們可…

Python字符串| isdecimal()方法與示例

isdecimal() is an in-built method in Python, which is used to check whether a string contains only decimal characters or not. isdecimal()是Python中的內置方法&#xff0c;用于檢查字符串是否僅包含十進制字符。 Note: 注意&#xff1a; Decimal characters contai…

zt:緩存一致性(Cache Coherency)入門 cach coherency

http://www.infoq.com/cn/articles/cache-coherency-primer http://www.cnblogs.com/xybaby/p/6641928.html english: http://www.tuicool.com/articles/BVRNZbV yxr注&#xff1a; 1) 由于曾研究IBM的CPU加速(CAPI)&#xff0c;其提到內存一致性&#xff0c;為了弄清楚其和通…

湖南省普通招生2021高考成績查詢,湖南省2021八省聯考成績可查,附查詢入口及往年分數線...

原標題&#xff1a;湖南省2021八省聯考成績可查&#xff0c;附查詢入口及往年分數線湖南省2021年八省聯考新高考適應性考試成績公布&#xff0c;這次大家考的如何呢&#xff1f;此次成績排名對于考生擇校及志愿填報有一定的參考意義&#xff0c;小盒一時間收集整理相關消息&…

duration java_Java Duration類| plusDays()方法與示例

duration java持續時間類plusDays()方法 (Duration Class plusDays() method) plusDays() method is available in java.time package. plusDays()方法在java.time包中可用。 plusDays() method is used to add the given duration in days to this Duration and return the Du…

Ubuntu拋棄了Untiy轉向Gnome,美化之路怎么辦?不用怕咱一步一步大變身!

跨平臺系列匯總&#xff1a;http://www.cnblogs.com/dunitian/p/4822808.html#linux 常用軟件安裝系統軟件卸載&#xff1a;http://www.cnblogs.com/dunitian/p/6670560.html 1.下載UnityGnome版本 https://wiki.ubuntu.com/UbuntuGNOME/GetUbuntuGNOME 2.打開終端 or CtrlAltT…

html木桶布局,CSS3如何實現圖片木桶布局?(附代碼)

本篇文章給大家通過代碼示例介紹一下使用CSS3實現圖片木桶布局的方法。有一定的參考價值&#xff0c;有需要的朋友可以參考一下&#xff0c;希望對大家有所幫助。高度相同&#xff0c;而寬度不一樣的布局&#xff0c;稱之為木桶布局。它有幾個鮮明的特點&#xff1a; 每行的圖片…

萬用表怎么測量電池容量_萬用表檢測光電耦合器的常用技巧

光電耦合器又稱光耦合器或光耦&#xff0c;它屬于較新型的電子產品&#xff0c;已經廣泛應用在彩色電視機、彩色顯示器、計算機、音視頻等各種控制電路中。光電耦合器的構成和原理常見的光電耦合器有 4 腳直插和 6 腳兩種&#xff0c;它們的典型實物外形和電路符號如圖 3-4所示…

c語言if else語句_查找C程序的輸出(如果為else語句)| 設置1

c語言if else語句Find the output of the following programs, 查找以下程序的輸出&#xff0c; Program 1) 程序1) #include <stdio.h>int main(){int x 400, y, z;if (x > 500)y 400;z 300;printf("%d %d\n", y, z);return 0;}Output 輸出量 32766 …

Javascript模塊化編程(二):AMD規范

這個系列的第一部分介紹了Javascript模塊的基本寫法&#xff0c;今天介紹如何規范地使用模塊。 七、模塊的規范 先想一想&#xff0c;為什么模塊很重要&#xff1f; 因為有了模塊&#xff0c;我們就可以更方便地使用別人的代碼&#xff0c;想要什么功能&#xff0c;就加載什么模…

html側滑菜單mui,mui側滑菜單點擊含有mui-action-menu類的控件無法實現側滑

.mui-action-menu標題欄 菜單按鈕 指定href"#id"顯示與隱藏側滑菜單html:側滑菜單列表側滑菜單列表2側滑菜單列表3標題具體內容href:https://badfl.gitbooks.io/mui/content/mui-action-menu.htmlAndroid 使用代碼主動去調用控件的點擊事件(模擬人手去觸摸控件)使用代…

hanlp 訓練模型_LTP 4.0!單模型完成6項自然語言處理任務

來源|哈工大SCIR語言技術平臺&#xff08;Language Technology Platform, LTP&#xff09;是哈工大社會計算與信息檢索研究中心&#xff08;HIT-SCIR&#xff09;歷時多年研發的一整套高效、高精度的中文自然語言處理開源基礎技術平臺。該平臺集詞法分析&#xff08;分詞、詞性…

typescript 學習

typescript將在不久的將來從前端大一統的趨勢中脫穎而出成為主流編譯器。學習ts對前端開發人員來說是不可或缺的。同時&#xff0c;也要抓緊學習es2015/6/7。ts和es6并不是對立的。而是相輔相成的。ts的競爭和打擊對象實質上是babel…… 官方資料 # 官方地址&#xff1a; https…

計算機中央處理器cpu_中央處理器(CPU)| 計算機科學組織

計算機中央處理器cpu中央處理器(CPU) (Central Processing Unit (CPU)) The CPU is the brain of the computer system. It works as an administrator of a system. CPU是計算機系統的大腦。 它以系統管理員的身份工作。 All the operations within the system are supervised…

計算機應用基礎專2020春,計算機應用基礎(專)(專,2020春)(20200831130023).pdf

計算機應用基礎(專)(專&#xff0c; 2020 春)使用 " 格式刷”按鈕&#xff0c;可以進行 ___________操作。選擇一項&#xff1a;a. 復制文本的格式b. 刪除文本c. 復制文本d. 保持文本你的回答正確正確答案是&#xff1a;復制文本的格式在 Word 的文檔中插入復雜的數學公式…