java 方法 示例_Java ArrayDeque帶有示例的removeFirstOccurrence()方法

java 方法 示例

ArrayDeque類removeFirstOccurrence()方法 (ArrayDeque Class removeFirstOccurrence() method)

  • removeFirstOccurrence() method is available in java.lang package.

    removeFirstOccurrence()方法在java.lang包中可用。

  • removeFirstOccurrence() method is used to remove the first occurrence of the given element in this deque.

    removeFirstOccurrence()方法用于刪除此雙端隊列中給定元素的首次出現。

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

    removeFirstOccurrence()方法是一個非靜態方法,僅可通過類對象訪問,如果嘗試使用類名訪問該方法,則會收到錯誤消息。

  • removeFirstOccurrence() method does not throw an exception at the time of removing the first occurrence of the given object.

    removeFirstOccurrence()方法在刪除給定對象的第一次出現時不會引發異常。

Syntax:

句法:

    public boolean removeFirstOccurrence (Object obj);

Parameter(s):

參數:

  • Object obj – represents the element to be removed of the first occurrence from this deque.

    對象obj –表示從此雙端隊列首次出現時要刪除的元素。

Return value:

返回值:

The return type of this method is boolean, it returns true if the given element is removed successfully, else it returns false.

此方法的返回類型為boolean ,如果成功刪除給定元素,則返回true ,否則返回false

Example:

例:

// Java program to demonstrate the example 
// of boolean removeFirstOccurrence(Object obj) 
// method of ArrayDeque 
import java.util.*;
public class RemoveFirstOccurrenceOfArrayDeque {
public static void main(String[] args) {
// Creating an ArrayDeque with initial capacity of
// storing elements
Deque < String > d_queue = new ArrayDeque < String > (10);
// By using add() method to add elements
// in ArrayDeque
d_queue.add("C");
d_queue.add("C++");
d_queue.add("Java");
d_queue.add("Php");
d_queue.add("DotNet");
d_queue.add("Java");
// Display Deque Elements
System.out.println("d_queue before removeFirstOccurrence(): ");
System.out.println("ArrayDeque Elements = " + d_queue);
System.out.println();
// By using removeFirstOccurrence() method to remove
// the first occurrence of the given element "Java"
d_queue.removeFirstOccurrence("Java");
System.out.println();
// Display Deque Elements
System.out.println("d_queue after removeFirstOccurrence(): ");
System.out.println("ArrayDeque Elements = " + d_queue);
}
}

Output

輸出量

d_queue before removeFirstOccurrence(): 
ArrayDeque Elements = [C, C++, Java, Php, DotNet, Java]d_queue after removeFirstOccurrence(): 
ArrayDeque Elements = [C, C++, Php, DotNet, Java]

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

java 方法 示例

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

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

相關文章

社交應用動態九宮格圖片的規則

這里主要以微信和QQ空間為作為研究對象&#xff0c;得到的結論如下。 QQ空間里的動態 iOS設備&#xff0c;以iPhone6為分界 iPhone6及以上分辨率的設備&#xff1a; 當寬且高同時 > 512px時&#xff0c;判斷 寬/高的比例值&#xff1a;大于 2時&#xff0c;以高度為基準&…

c語言實現鏈表結構6,用c語言實現的鏈表結構--數據結構實驗

該樓層疑似違規已被系統折疊 隱藏此樓查看此樓#include"stdio.h"//使用new指針來將臨時變量重新初始化#include"stdio.h"typedef int ElemType;typedef struct LNode{ElemType data;struct LNode *next;}LNode,*LinkList;void InitList(LinkList &L)//…

splunk中 如何隱藏input_翻糖制作中,如何避免裂縫,如何隱藏裂縫,如何防粘?...

翻糖蛋糕 因精致的樣子和栩栩如生的各種造型深得人們的喜愛&#xff0c;它不僅滿足了人們對蛋糕口味及裝飾日益多樣化的需求&#xff0c;同時也在動手制作的過程中&#xff0c;享受到美食與生活的無窮樂趣。不過裂縫&#xff0c;不平整&#xff0c;干燥對翻糖作品來說無疑是噩夢…

Java DataInputStream readUnsignedByte()方法(帶示例)

DataInputStream類readUnsignedByte()方法 (DataInputStream Class readUnsignedByte() method) readUnsignedByte() method is available in java.io package. readUnsignedByte()方法在java.io包中可用。 readUnsignedByte() method is used to read 1 byte (i.e. 8 bit) of …

wpf中groupbox有什么用_展示設計中的標攤是什么 用的什么材料

經常聽從事展示設計的工作人員說起標攤&#xff0c;那什么是標攤呢&#xff1f;顧名思義&#xff0c;標攤就是通用標準的國際展會攤位的縮寫。但是不少人看到干巴巴的詞語還是不能理解。那么這篇文章從用途、材料等方面來詳細介紹標攤究竟是什么。 標攤的主要材質是什么一般來說…

Java BigInteger類| nextProbablePrime()方法與示例

BigInteger類nextProbablePrime()方法 (BigInteger Class nextProbablePrime() method) nextProbablePrime() method is available in java.math package. nextProbablePrime()方法在java.math包中可用。 nextProbablePrime() method is used to get the next probable prime n…

SQL 行轉列的兩種做法

if object_id(tb)is not null drop table tbGocreate table tb(姓名 varchar(10),課程 varchar(10),分數 int)insert into tb values(張三,語文,74)insert into tb values(張三,數學,83)insert into tb values(張三,物理,93)insert into tb values(李四,語文,74)insert into tb…

android一個工程的xml怎么引用另外一個工程的xml,如何在Android中使用XML引用庫中另一個包的字符串?...

Androiddocumentation告訴我,我可以使用“包名”訪問另一個包中的字符串,無論這意味著什么&#xff1a;[:]/所以在我的清單中,我想訪問一個字符串,我已將其放在一個單獨的庫項目中,在com.globalmentor.android包中 – 畢竟我的R類就是這樣&#xff1a;android:label"com.g…

kotlin 類和對象_Kotlin程序| 類和對象的示例(帶有學生數據)

kotlin 類和對象In the below program, we are creating a student class to input and print the student data like name, age. It is a simple example of creating class in Kotlin. 在下面的程序中&#xff0c;我們將創建一個學生班級&#xff0c;以輸入和打印學生數據&am…

python 復數數組_python的數組運算及推導式的運用

運行方式&#xff1a;縮進 TAb(四格)或者space(1格)注釋&#xff1a;#可以在程序后注釋文字 或者 ... &#xff0c;""" ... """ 可以多行注釋 中間全為注釋數值輸出 print(...)圖形輸出 import matplotlib as pltplt.show()列表 list[] #字符串…

ActiveX: 如何用.inf和.ocx文件生成cab文件

ActiveX: 如何用.inf和.ocx文件生成cab文件 轉載于:https://www.cnblogs.com/time-is-life/p/5977962.html

Android工具里沒有Android,android – AppCompat工具欄沒有顯示

在主題中聲明.NoActionBar之后,以及將工具欄放在布局中,我的工具欄不會顯示.我最終得到的正是你在宣布沒有動作欄時所期望的 – 沒有動作欄.這是布局&#xff1a;activity_home.xml&#xff1a;layout"layout/app_bar_home"android:layout_width"match_parent&q…

操作系統中的處理機調度調度_操作系統中的多處理器調度

操作系統中的處理機調度調度多處理器操作系統 (Multiprocessor Operating system) A multiprocessor system consists of several processors which share memory. In the multiprocessor, there is more than one processor in the system. The reason we use multiprocessor …

轉:Delphi2010新發現-類的構造和析構函數功能

Delphi2010發布了. 雖然憑著對Delphi的熱愛第一時間就安裝了,但是現在可能是年紀大了,對新事物缺乏興趣了.一直都沒有仔細研究. 今天有點時間試了一下新功能. 本來C#和Delphi.NET是支持類的構造函數/析構函數的(注意不是實例的構造和析構).也就是在模塊初始化/卸載的時候會調用…

sed 替換_sed命令批量替換文件內容

“ 開發人員有時會大批量替換文件內容&#xff0c;sed命令是一個很好用的工具。”01—暴力替換方式近期有個臨時任務,將系統中所有"帳"替換為"賬",那"帳"和"賬"有啥區別呢;1、賬的部首是貝&#xff1b;帳的部首是巾。2、賬是關于貨幣、…

android 模仿uc標簽頁,模仿UCweb菜單 - 白羽雕弓 - 博客園

UCWeb的菜單看起來不錯&#xff0c;自己想模仿做一個&#xff0c;苦惱一直沒有思路google了幾天&#xff0c;終于找到一個帖子 http://www.eoeandroid.com/viewthread.php?tid28824按照上面提供的思路實現了1、保留menu按鍵作用2、用popupwindow作為菜單顯示容器3、用GridVie…

ipv6路由協議配置_IPV6尋址,標頭和路由協議

ipv6路由協議配置The IPV6 address is 128 bits. Whereas IPV4 is represented by 4 groups of decimal numbers, same IPV6 is represented by 8 groups of hexadecimal numbers. The example of IPV6 address is 2001:0db8:85a3:0000:0000:8a2e:0370:7334. IPV6地址是128位。…

rpc框架

Motan&#xff0c;dubbo轉載于:https://www.cnblogs.com/zhangshiwen/p/5980886.html

android webview 監聽js,Android webview與js的數據交互

項目要用到Webview和js交互&#xff0c;查了查以前的項目感覺還是有必要整理下的。簡單描述下項目中用到的地方&#xff0c;比如說在web頁需要用到登錄的地方點擊登錄跳轉到APP原生登錄界面去登錄&#xff0c;點擊web頁的撥打電話彈出原生dialog詢問是否撥打&#xff0c;點擊we…

c ++查找字符串_C ++異常處理| 查找輸出程序| 套裝1

c 查找字符串Program 1: 程序1&#xff1a; #include <iostream>using namespace std;int main(){try {int num1 10;int num2 0;int res 0;res num1 / num2;}catch (exception e) {cout << "Exception: Divide By Zero" << endl;}return 0;}O…