Java ArrayList isEmpty()方法與示例

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

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

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

  • isEmpty() method is used to check whether this Arraylist is "empty" or "not empty".

    isEmpty()方法用于檢查此Arraylist是“空”還是“非空”。

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

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

  • isEmpty() method does not throw an exception at the time of checking the status of an empty Arraylist.

    在檢查空Arraylist的狀態時, isEmpty()方法不會引發異常。

Syntax:

句法:

    public boolean isEmpty();

Parameter(s):

參數:

  • It does not accept any parameter.

    它不接受任何參數。

Return value:

返回值:

The return type of this method is boolean, it returns true when this Arraylist is "empty" otherwise it returns false when this Arraylist is "non-empty".

此方法的返回類型為boolean ,當此Arraylist為“空”時返回true;否則,當此Arraylist為“非空”時返回false。

Example:

例:

// Java program to demonstrate the example 
// of boolean isEmpty() method of ArrayList
import java.util.*;
public class EmpytArrayList {
public static void main(String[] args) {
// Create an ArrayList with initial 
// capacity of storing elements
ArrayList arr_l = new ArrayList(10);
// 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 isEmpty() method is to check
// the empty ArrayList
boolean status = arr_l.isEmpty();
// Display status of the given ArrayList
System.out.println("arr_l.isEmpty() : " + status);
}
}

Output

輸出量

ArrayList Elements :[C, C++, JAVA, DOTNET, PHP]
arr_l.isEmpty() : false

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

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

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

相關文章

linux家用系統版本,查看linux系統版本

篇一:linux下如何查看系統和內核版本linux下如何查看系統和內核版本 1. 查看內核版本命令:1) [rootq1test01 ~]# cat /proc/versionLinux version 2.6.9-22.ELsmp (bhcompilecrowe.devel.redhat.com) (gcc version 3.4.4 20050721 (Red Hat 3.4.4-2)) #1…

python中locked_Python鎖類| 帶示例的locked()方法

python中lockedPython Lock.locked()方法 (Python Lock.locked() Method) locked() is an inbuilt method of the Lock class of the threading module in Python. Locked()是Python中線程模塊的Lock類的內置方法。 This method returns True if the lock is acquired by a th…

rocksdb ubuntu c++源碼編譯測試

2019獨角獸企業重金招聘Python工程師標準>>> 環境: ubuntu16.4 需要安裝 snappy gflage bz2 zstd 以及g 其中zstd是facebook開放源代碼里的壓縮的庫 git clone https://github.com/facebook/rocksdb.git cd rocksdb make static_lib 成功生成 librocksd…

vs生成linux服務器程序,從Visual Studio到Linux上調試C++代碼

從Visual Studio到Linux上調試C代碼04/30/20155 分鐘可看完本文內容[原文發表時間] 2015/4/29 10:00 PM正如您可能已經聽說的那樣,Visual Studio 2015新推出了對Android開發的GDB支持。有趣的是,因為這項功能依賴GDB調試,我們完全可能稍加改動…

java clock計時_Java Clock類| 實例的Instant()方法

java clock計時Clock Class Instant()方法 (Clock Class instant() method) instant() method is available in java.time package. Instant()方法在java.time包中可用。 instant() method is used to get the current instant that is used with this Clock. Instant()方法用于…

使用國內DOCKER鏡像源

在國內,通過Docker的pull和push命令訪問hub.docker時,網絡十分慢,而且會出現各種各樣的網絡連接問題。因此這里介紹下如何使用國內的鏡像源,這里以DaoCloud為例。注冊DaoCloud用戶;注冊完成后,會進入dashboard頁面&…

linux命令top查看進程,linux 查看進程的命令(top)

標簽:top操作系統支持多任務并不是計算機同時做很多事情,而是快速的輪換著執行這些任務。linux安排不同的程序等待使用CPU。進程的工作方式:當系統啟動的時候,內核先把自己的程序初始化為進程,然后運行一個init的程序&…

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

stl vector 函數C vector :: back()函數 (C vector::back() function) vector::back() is a library function of "vector" header, it is used to access the last element from the vector, it returns a reference to the last element of the vector. vector ::…

linux udp 端口 抓包,tcpdump之UDP抓包

摘要使用tcpdump抓UDP包,過濾過濾IP和port,并且自動拆分片段。安裝tcpdumpyum install -y tcpdump使用方法tcpdump -i bond0 udp port xxxx and host xxx.x.xx.xxx -s0 -G 600 -w %Y_%m%d_%H%M_%S.pcap參數說明-i 指定監聽的網卡udp 監聽UDP協議port 指定…

Vue版本過渡變化

到了2.0以后&#xff0c;有哪些變化&#xff1a; 在每個組件模板&#xff0c;不在支持片段代碼之前: <template id”aaa”><h3>我是組件</h3><strong>我是加粗標簽</strong></template> 現在: 必須有根元素&#xff0c;包裹住所有的代碼 …

NABARD的完整形式是什么?

NABARD&#xff1a;國家農業和農村發展銀行 (NABARD: National Bank for Agriculture and Rural Development) NABARD is an abbreviation of National Bank for Agriculture and Rural Development. NABARD是國家農業和農村發展銀行的縮寫 。 On 12 July 1982, it was establ…

基于opencv+Dlib的面部合成(Face Morph)

引自&#xff1a;http://blog.csdn.net/wangxing233/article/details/51549880 零、前言 前段時間看到文章【1】和【2】&#xff0c;大概了解了面部合成的基本原理。這兩天空下來了&#xff0c;于是參考【3】自己實現了下。雖然【1】和【2】已經講的很清楚了&#xff0c;但是有…

大腦應對危機的模式_危機的完整形式是什么?

大腦應對危機的模式危機&#xff1a;印度信用評級信息服務有限公司 (CRISIL: Credit Rating Information Services of India Limited) CRISIL is an abbreviation of Credit Rating Information Services of India Limited. It is an international analytic company which off…

linux網絡延遲命令,2. Linux使用ping命令查看網絡延遲

ping命令持續發送少量互聯網流量到遠程地址并報告收到回應的總時間。如果流量因為網絡故障或者錯誤配置而被丟棄&#xff0c;它也會報告。ping命令是最基本和初級的診斷網絡問題的工具之一。ping常被用來測試網絡延遲&#xff0c;但是有時ping的延遲并不是網絡引起的&#xff0…

一、簡單工廠模式

# public class Operation //基類{private double _numberA 0;private double _numberB 0;public double NumberA{get{ return _numberA; }set{_numberA value;}}public double NumberB{get{ return _numberB; }set{_numberB value;}}public virtual double GetResult(){d…

軟件生命周期模型及其類型

A life cycle model is also known as a process model. As the name suggests, the software life cycle model (or the software process model) gives us a pictorial representation of the entire software development process. 生命周期模型也稱為過程模型 。 顧名思義&…

linux查看磁盤io帶寬,[Linux] 磁盤IO性能查看和優化以及iostat命令

iostat命令:%user&#xff1a;CPU處在用戶模式下的時間百分比。%nice&#xff1a;CPU處在帶NICE值的用戶模式下的時間百分比。%system&#xff1a;CPU處在系統模式下的時間百分比。%iowait&#xff1a;CPU等待輸入輸出完成時間的百分比。%steal&#xff1a;管理程序維護另一個虛…

Jsoup 數據修改

2019獨角獸企業重金招聘Python工程師標準>>> 1 設置屬性的值 在解析一個Document之后可能想修改其中的某些屬性值&#xff0c;然后再保存到磁盤或都輸出到前臺頁面。 可以使用屬性設置方法 Element.attr(String key, String value), 和 Elements.attr(String key, S…

軟件靜態架構 軟件組件圖_組件圖| 軟件工程

軟件靜態架構 軟件組件圖什么是組件圖&#xff1f; (What is Component Diagram?) A Component Diagram breaks down the real system under development into different heights of working. Every component is reactive for the main aim in the entire system and only re…

如何卸載非linux系統分區,如何卸載Linux系統分區?卸載Linux系統分區的方法-站長資訊中心...

系統為windows xp sp2和redhat as 5雙系統&#xff0c;其中linux系統后安裝的在D盤&#xff0c;華彩軟件站www.huacolor.com小編今天發現硬盤不夠用了&#xff0c;想干掉linux分區&#xff0c;在虛擬機中用linux。就在windows的磁盤管理(命令為:diskmgmt)下刪除linux分區&#…