element 項目 示例_Java ArrayDeque element()方法與示例

element 項目 示例

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

  • element() Method is available in java.lang package.

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

  • element() Method is used to retrieve the first element of the deque but without removing the element from this deque.

    element()方法用于檢索雙端隊列的第一個元素,但不從此雙端隊列中刪除該元素。

  • element() 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.

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

  • element() Method may throw an exception at the time of retrieving element.

    element()方法在檢索element時可能會引發異常。



  • NoSuchElementException: This exception may throw when the deque is “blank” (i.e. Deque contains no elements). NoSuchElementException :當雙端隊列為“空白”時(即雙端隊列不包含任何元素),可能會引發此異常。

Syntax:

句法:

    public T element();

Parameter(s):

參數:

  • It does not accept any parameter.

    它不接受任何參數。

Return value:

返回值:

The return type of the method is T, it returns first element of this deque.

方法的返回類型為T ,它返回此雙端隊列的第一個元素。

Example:

例:

// Java program to demonstrate the example 
// of T element() method of ArrayDeque 
import java.util.*;
public class ElementOfArrayDeque {
public static void main(String[] args) {
// Creating an ArrayDeque with initial capacity of
// storing elements
ArrayDeque < 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");
// Display Deque Elements
System.out.println("d_queue : ");
System.out.println("ArrayDeque Elements = " + d_queue);
System.out.println();
// By using element() method is to return the
// first element of ArrayDeque
String ele = d_queue.element();
System.out.println("d_queue.element() : " + ele);
}
}

Output

輸出量

d_queue : 
ArrayDeque Elements = [C, C++, Java, Php, DotNet]d_queue.element() : C

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

element 項目 示例

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

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

相關文章

can收發器 rx_CANOpen系列教程03 _CAN收發器功能、原理及作用

1寫在前面前面文章是從大方向介紹了CAN網絡&#xff0c;讓大家對CAN網絡有一定的認識。本文將范圍縮小&#xff0c;講述整個CAN網絡其中的一個CAN收發器。如下圖標記出來的部分&#xff1a;本文結合眾多初學者容易產生的疑問來講述CAN收發器相關的知識點&#xff0c;大概有如下…

操作系統文件分配策略_操作系統中的文件分配方法

操作系統文件分配策略分配方法 (Allocation Method) The allocation method defines how the files are stored in the disk blocks. The direct access nature of the disks gives us the flexibility to implement the files. In many cases, different files or many files …

簡述container與container-fluid的區別

在bootstrap中的布局容器一欄中&#xff0c;提供了container與container-fluid兩種容器&#xff0c;其官方解釋為&#xff1a; .container 類用于固定寬度并支持響應式布局的容器。 .container-fluid 類用于 100% 寬度&#xff0c;占據全部視口&#xff08;viewport&#xff09…

centos php fpm 停止_如何關閉php-fpm進程?

因為你是編譯的&#xff0c;可以在源碼中復制php-fpm的init文件到系統中&#xff1a;cp -f sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm然后就可以使用以下命令啟動、停止、重啟和重新加載php-fpm了&#xff1a;service php-fpm startservice php-fpm restartservice php-fpm…

minus_Java Duration類| minus()方法與示例

minus持續時間類minus()方法 (Duration Class minus() method) Syntax: 句法&#xff1a; public Duration minus(Duration d);public Duration minus(long amt, TemporalUnit t_unit);minus() method is available in java.time package. minus()方法在java.time包中可用。 m…

Mongodb聚合函數

插入 測試數據 for(var j1;j<3;j){ for(var i1;i<3;i){ var person{Name:"jack"i,Age:i,Address:["henan","wuhan"],Course:[{Name:"shuxue",Score:i},{Name:"wuli",Score:i}]}db.DemoTest.Person.insert(pers…

php rename函數_php rename函數怎么用

PHP rename()函數用于重命名文件或目錄&#xff0c;語法“rename(文件舊名稱,新名稱,句柄環境)”&#xff0c;使用用戶指定的新名稱更改文件或目錄的舊名稱&#xff0c;并且可以根據需要在目錄之間移動&#xff1b;成功時返回True&#xff0c;失敗時返回False。php rename()函數…

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

BigInteger類的xor()方法 (BigInteger Class xor() method) xor() method is available in java.math package. xor()方法在java.math包中可用。 xor() method is used to perform xor operation between this BigInteger and the given BigInteger and we all know when we pe…

Spring Data Redis實戰之提供RedisTemplate

為什么80%的碼農都做不了架構師&#xff1f;>>> 參考&#xff1a; http://www.cnblogs.com/edwinchen/p/3816938.html 本項目創建的是Maven項目 一、pom.xml引入dependencies <dependency><groupId>org.springframework.data</groupId><artif…

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

BigInteger類和()方法 (BigInteger Class and() method) and() method is available in java.math package. and()方法在java.math包中可用。 and() method is used to perform and operation between this BigInteger and the given BigInteger (val) [i.e. (this BigInteger)…

php映射,PHP實現路由映射到指定控制器

自定義路由的功能&#xff0c;指定到pathinfo的url上,再次升級之前的腳本SimpleLoader.phpclass SimpleLoader{public static function run($rulesarray()){header("content-type:text/html;charsetutf-8");self::register();self::commandLine();self::router($rule…

stl vector 函數_vector :: clear()函數,以及C ++ STL中的示例

stl vector 函數C vector :: clear()函數 (C vector::clear() function) vector::clear() is a library function of "vector" header, it is used to remove/clear all elements of the vector, it makes the 0 sized vector after removing all elements. vector …

Commonjs規范及Node模塊實現

前面的話 Node在實現中并非完全按照CommonJS規范實現&#xff0c;而是對模塊規范進行了一定的取舍&#xff0c;同時也增加了少許自身需要的特性。本文將詳細介紹NodeJS的模塊實現 引入 nodejs是區別于javascript的&#xff0c;在javascript中的頂層對象是window&#xff0c;而在…

thinkphp3 php jwt,ThinkPHP5 使用 JWT 進行加密

- 使用 Composer安裝此擴展- 代碼示例<?php /*** [InterCommon-接口公用]* Author RainCyan* DateTime 2019-08-12T16:38:080800*/namespace app\hladmin\controller;use think\Controller;use \Firebase\JWT\JWT;class InterCommonController extends Controller {private…

數據管理與商業智能_商業智能與數據科學

數據管理與商業智能In this heavily jargonized trade, the words typically overlap one another, leading to a scarcity of understanding or a state of confusion around these ideas. whereas big data vs analytics or computing vs machine learning vs cognitive inte…

JavaWeb網上圖書商城完整項目--day02-14.登錄功能的login頁面處理

1、現在注冊成功之后&#xff0c;我們來到登錄頁面&#xff0c;登錄頁面在于 在登錄頁面。我們也需要向注冊頁面一樣對登錄的用戶名、密碼 驗證碼等在jsp頁面中進行校驗&#xff0c;校驗我們單獨放置一個login.js文件中進行處理&#xff0c;然后login.jsp加載該js文件 我們來看…

php多線程是什么意思,多線程是什么意思

線程是操作系統能夠進行運算調度的最小單位&#xff0c;它被包含在進程之中&#xff0c;是進程中的實際運作單位&#xff0c;而多線程就是指從軟件或者硬件上實現多個線程并發執行的技術&#xff0c;具有多線程能力的計算機因有硬件支持而能夠在同一時間執行多于一個線程&#…

c++一個類創建多個對象_C ++ | 創建一個類的多個對象

c一個類創建多個對象In the below program, we are creating a C program to create multiple objects of a class. 在下面的程序中&#xff0c;我們正在創建一個C 程序來創建一個類的多個對象 。 /* C program to create multiple objects of a class */#include <iostrea…

Activity中與ListActivity中使用listview區別

一.Activity中與ListActivity中使用listview區別&#xff08;本身沒多大區別&#xff0c;只是ListActivity在listview的顯示上做了一些優化&#xff09;Activity中使用Listview步驟&#xff1a;1.xml布局中,ListView標簽id可以任意取值如&#xff1a;<ListView andro…

java相關是什么,什么是java

java基礎常見面試題&#xff0c;這是一篇超長的隨筆&#xff01;&#xff01;&#xff01;1. Java基礎部分....................................................... 4 1、一個".java"源文件中是否可以包括多個類(不是內部類)&#xff1f;有什么限制&#xff1f;.. …