Java Vector Capacity()方法與示例

向量類的Capacity()方法 (Vector Class capacity() method)

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

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

  • capacity() method is used to return the current capacity (i.e. initially, how many object exists) of this Vector object.

    Capacity()方法用于返回此Vector對象的當前容量(即,最初存在多少個對象)。

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

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

  • capacity() method does not throw an exception at the time of returning capacity.

    Capacity()方法在返回容量時不會引發異常。

Syntax:

句法:

    public int capacity();

Parameter(s):

參數:

  • It does not accept any parameter.

    它不接受任何參數。

Return value:

返回值:

The return type of the method is int, it gets the current capacity of this Vector.

方法的返回類型為int ,它獲取此Vector的當前容量。

Example:

例:

// Java program to demonstrate the example 
// of int capacity() method of Vector 
import java.util.*;
public class CapacityOfVector {
public static void main(String[] args) {
// Instantiates a Vector object  with
// initial capacity of "10"
Vector < String > v = new Vector < String > (10);
// By using add() method is to add the
// elements in this v
v.add("C");
v.add("C++");
v.add("JAVA");
// By using size() methos is to return the 
// size i.e. the number of element exists
// Display Vector Size
System.out.println("v.size(): " + v.size());
// By using capacity() method is to return the 
// Vector capacity
// Display Vector Capacity
System.out.println("v.capacity(): " + v.capacity());
}
}

Output

輸出量

v.size(): 3
v.capacity(): 10

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

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

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

相關文章

MFC和GTK的區別

關鍵技術 http://blog.csdn.net/master_max/article/details/1540204 MFC和GTK的區別&#xff1f;&#xff1f; 1.  兩者都是基于面向對象設計的。盡管MFC是用C寫的&#xff0c;而GTK是用C寫的&#xff0c;但思想都是面向對象的。GTK使用glib的對象機制&#xff0c;由于用C寫…

視頻圖像質量評價

目錄1、人眼視覺特性1、眼的適應性2、對比靈敏度3、空間分辨率和時間分辨率4、馬赫效應5、可見度閾值2、圖像質量測度3、圖像評價方法4、圖像評價方法的優劣1、人眼視覺特性 1、眼的適應性 暗適應性&#xff1a;從亮環境到暗環境&#xff0c;適應暗環境的特性 亮適應性&#…

鴻蒙科技與文化,數字閱讀 | “華為鴻蒙”:當現代科技遇到古典文化

華為事件愈演愈烈。海思芯片 20 年 " 備胎 " 終轉正&#xff0c;那么操作系統呢&#xff1f;最近&#xff0c;華為為自主研發的操作系統注冊商標—— " 鴻蒙 "&#xff0c;引發了關于華為注冊整本《山海經》的熱烈討論&#xff0c;很多人的朋友圈&#xff…

三、Beautiful Soup解析庫

一、Beautiful Soup介紹與安裝 1&#xff0c;Beautiful Soup介紹 答&#xff1a;Beautiful Soup是一個可以從HTML或XML文件中提取數據的Python庫 2&#xff0c;Beautiful Soup安裝 答&#xff1a;安裝Beautiful Soup 4&#xff1a;pip install bs4 安裝lxml&#xff1a;pip…

strictmath_Java StrictMath sqrt()方法與示例

strictmathStrictMath類sqrt()方法 (StrictMath Class sqrt() method) sqrt() Method is available in java.lang package. sqrt()方法在java.lang包中可用。 sqrt() Method is used to find the square root of the given parameter in the method. Here, "sqrt" st…

recovery編譯問題匯總

1、修改支持USB大容量存儲 &#xff08;1&#xff09;、首先需要查看手機lun位置 手機鏈接電腦&#xff0c;打開cmd命令行&#xff0c;依次輸入以下命令: adb shell find /sys -name "lun" 輸出以下結果&#xff1a; 發現手機輸出結果有兩個&#xff0c;需要進一步查…

言語理解每日學習及精解20110831

【例題】天氣預報一般要考慮氣溫、氣壓、溫度、風力等因素&#xff0c;這些都是大氣層本身變化的結果&#xff0c;只要掌握這些因素&#xff0c;通過計算機的計算就能準確地預報天氣變化的趨勢。沙塵暴作為一種特殊的天氣現象&#xff0c;同樣要考慮上述氣象因素。據氣象學家分…

【數據結構基礎筆記】【棧】

代碼參考《妙趣橫生的算法.C語言實現》 文章目錄前言1、棧的定義2、創建一個棧3、入棧和出棧操作4、棧的清空、銷毀、計算棧的當前容量5、實例分析前言 本章總結&#xff1a;棧的定義、創建棧&#xff0c;銷毀棧&#xff0c;入棧出棧操作等操作。 1、棧的定義 棧是一種重要的…

四、正則表達式

一、正則表達式的概念和作用 正則表達式概念&#xff1a;一種字符串匹配的模式 正則表達式作用&#xff1a; 可以檢查一個字符串中是否包含某種字串替換匹配的字串提取某個字符串中匹配的字串 二、正則表達式中常見的語法 字符描述原樣字符匹配字符一般字符匹配自身beyondb…

用HTML語言制作list標記,html5 datalist標簽的用法是什么?這里有datalist標簽的用法實例...

本篇文章主要為大家講述了關于html5 datalist標簽的用法及html5 datalist標簽的用法實例。本文說了兩個常用的選項框的實例供大家選擇觀看&#xff0c;下面就讓我們一起來看這篇文章吧我們先來看看html5 datalist標簽的用法&#xff1a;標簽定義選項列表。請與input元素配合使用…

java treemap_Java TreeMap lastKey()方法與示例

java treemapTreeMap類lastKey()方法 (TreeMap Class lastKey() method) lastKey() method is available in java.util package. lastKey()方法在java.util包中可用。 lastKey() method is used to return the last highest key element value exists in this TreeMap. lastKey…

網上看來的

http://blog.163.com/dong_xiao_yang/blog/static/216138205201321114659430/ http://ffmpeg.org/trac/ffmpeg/wiki/How%20to%20compile%20FFmpeg%20for%20Raspberry%20Pi%20%28Raspbian%29#FFmpegwithlibaacpluslibx264andalsa-lib 編譯環境 Ubuntu 12.04 w64-mingw32下載lib…

閱讀iPhone.3D.Programming(O'Reilly.2010-05) 英文版 第一感覺

最近開始閱讀iPhone.3D.Programming(OReilly.2010-05)&#xff0c;英文版此書&#xff0c;我閱讀到P21了&#xff0c;中間講了一個樣例&#xff0c;HelloArrow在這個過程中&#xff0c;我想簡單點&#xff0c;少打點字&#xff0c;直接拿書中配套來學習&#xff0c;發現一個問題…

【數據結構基礎筆記】【隊列】

代碼參考《妙趣橫生的算法.C語言實現》 文章目錄前言1、隊列定義2、創建一個隊列3、入隊列4、出隊列5、銷毀一個隊列6、循環隊列的概念7、循環隊列的實現8、實例分析前言 本章總結&#xff1a;鏈隊列定義&#xff0c;創建&#xff0c;出隊入隊操作&#xff0c;銷毀操作&#x…

html圖片自動循環輪播圖,js實現圖片無縫循環輪播

本文實例為大家分享了js實現圖片無縫循環輪播的具體代碼&#xff0c;供大家參考&#xff0c;具體內容如下代碼如下Document#container{overflow:hidden;width:400px;height:300px;margin:auto;}#front,#container{display:flex;flex-direction:row;}#container img{width:400px…

五、json模塊

一、json模塊的介紹 json模塊是Python自帶的模塊&#xff0c;用于json和Python數據之間的相互轉換 Json與Python數據類型的對應關系 JsonPythonobjectdictarrayliststringstrnumber(int)int,longnumber(real)floattrueTruefalseFalsenullNone [#中括號括起來的&#xff0c;對…

Android開發和調試必備工具-SDK Tools

原文鏈接&#xff1a;http://android.eoe.cn/topic/android_sdk SDK Tools是Android SDK的一個可下載部分&#xff0c;它包括Android SDK的開發和調試的所有工具。 如果你剛剛了解SDK&#xff0c;你可以從SDK starter package下載最新版本的SDK。 如果你已經在使用SDK&#xff…

strictmath_Java StrictMath ceil()方法與示例

strictmathStrictMath類ceil()方法 (StrictMath Class ceil() method) ceil() method is available in java.lang package. ceil()方法在java.lang包中可用。 ceil() method is used to return the least or smallest value of the double type value which is greater than or…

web應用之文件上傳

一、Jakart:Jakart文件上傳&#xff1a;&#xff08;推薦使用&#xff09; import java.io.File;import java.io.IOException;import java.util.List; import javax.servlet.ServletException;import javax.servlet.http.HttpServlet;import javax.servlet.http.HttpServletReq…

【數據結構基礎筆記】【樹】

代碼參考《妙趣橫生的算法.C語言實現》 文章目錄前言1、樹的概念2、二叉樹3、二叉樹的遍歷4、創建二叉樹5、實例分析前言 本章總結&#xff1a;樹的概念、二叉樹的創建、遍歷 1、樹的概念 樹結構是以分支關系定義得一種層次結構。 樹的定義&#xff1a;樹是由n(n>0)個結點…