java vector_Java Vector size()方法與示例

java vector

矢量類size()方法 (Vector Class size() method)

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

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

  • size() method is used to return the size (i.e. the number of the element exists) of this Vector.

    size()方法用于返回此Vector的大小(即元素存在的數量)。

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

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

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

    返回size時, size()方法不會引發異常。

Syntax:

句法:

    public int size();

Parameter(s):

參數:

  • It does not accept any parameter.

    它不接受任何參數。

Return value:

返回值:

The return type of the method is int, it returns the size of this vector.

方法的返回類型為int ,它返回此向量的大小。

Example:

例:

// Java program to demonstrate the example 
// of int size() method of Vector 
import java.util.*;
public class SizeOfVector {
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());
}
}

Output

輸出量

v.size(): 3

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

java vector

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

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

相關文章

二、線性回歸

一、回歸 可以拿正態分布為例&#xff0c;比如身高&#xff0c;若平均身高為1.78m&#xff0c;絕大多數人都是1.78m左右&#xff0c;超過2m的很少&#xff0c;低于1m的也不多。 很多事情都會回歸到一定的區間之內&#xff0c;即回歸到平均值。 機器學習沒有完美解&#xff0c…

【轉】HMM學習最佳范例五:前向算法1 .

五、前向算法&#xff08;Forward Algorithm&#xff09; 計算觀察序列的概率&#xff08;Finding the probability of an observed sequence&#xff09; 1.窮舉搜索&#xff08; Exhaustive search for solution&#xff09;  給定隱馬爾科夫模型&#xff0c;也就是在模型參…

vs 字體

看代碼看得眼疼不能不說是程序員的惡夢&#xff0c;那么&#xff0c;選擇適當的字體也算是對自己的救贖吧。周末閑得無聊&#xff0c;在網上亂逛&#xff0c;搜索了一些資料整理一下給大家分享&#xff0c;僅作記錄而已&#xff0c;參考使用&#xff1a; 1.一個編程人員痛苦的選…

leetcode 349. 兩個數組的交集 思考分析

題目 給定兩個數組&#xff0c;編寫一個函數來計算它們的交集。 1、暴力雙for循環 class Solution { public:vector<int> intersection(vector<int>& nums1, vector<int>& nums2) {vector<int> result;vector<int> res;if(nums1.siz…

random.next_Java Random next()方法與示例

random.next隨機類的next()方法 (Random Class next() method) next() method is available in java.util package. next()方法在java.util包中可用。 next() method is used to return the pseudo-random number in bits. next()方法用于返回以位為單位的偽隨機數。 next() me…

VS2008下QT開發環境搭建

http://blog.csdn.net/sunnyboycao/article/details/6364444 轉載于:https://www.cnblogs.com/bjfuyumu/p/3321180.html

三、梯度下降法求解最優θ值

一、梯度下降法(GD&#xff0c;Gradient Descent) Ⅰ、得到目標函數J(θ)&#xff0c;求解使得J(θ)最小時的θ值 當然&#xff0c;這里只是取了倆特征而已&#xff0c;實際上會有m個特征維度 通過最小二乘法求目標函數最小值 令偏導為0即可求解出最小的θ值&#xff0c;即…

Delphi中Messagedlg用法

if MessageDlg(Welcome to my Delphi application. Exit now?, mtConfirmation, [mbYes, mbNo], 0) mrYes then begin Close; end;MessageDlg用法 對話框類型&#xff1a;mtwarning——含有感嘆號的警告對話框mterror——含有紅色叉符號的錯誤對話框mtinformation——含有藍…

leetcode 131. 分割回文串 思考分析

題目 給定一個字符串 s&#xff0c;將 s 分割成一些子串&#xff0c;使每個子串都是回文串。 返回 s 所有可能的分割方案。 思考 問題可以分為兩個子問題&#xff1a;1、判斷回文串2、分割數組 判斷回文串 bool isPalindrome_string(string s,int startindex,int endinde…

android淡入淡出動畫_在Android中淡入動畫示例

android淡入淡出動畫1) XML File: activity_main 1)XML文件&#xff1a;activity_main <?xml version"1.0" encoding"utf-8"?><android.support.constraint.ConstraintLayout xmlns:android"http://schemas.android.com/apk/res/android&…

[慢查優化]聯表查詢注意誰是驅動表 你搞不清楚誰join誰更好時請放手讓mysql自行判定...

寫在前面的話&#xff1a; 不要求每個人一定理解 聯表查詢(join/left join/inner join等)時的mysql運算過程&#xff1b; 不要求每個人一定知道線上&#xff08;現在或未來&#xff09;哪張表數據量大&#xff0c;哪張表數據量小&#xff1b; 但把mysql客戶端&#xff08;如SQL…

四、梯度下降歸一化操作

一、歸一化 Ⅰ什么是歸一化&#xff1f; 答&#xff1a;其實就是把數據歸一到0-1之間&#xff0c;也就是縮放。 常用的歸一化操作是最大最小值歸一化&#xff0c;公式如下&#xff1a; 例如&#xff1a;1&#xff0c;3&#xff0c;5&#xff0c;7&#xff0c;9&#xff0c;10…

[轉帖][強烈推薦]網頁表格(Table/GridView)標題欄和列凍結(跨瀏覽器兼容)

GridView的標題欄、列凍結效果(跨瀏覽器版) 本文來源&#xff1a;http://blog.darkthread.net/blogs/darkthreadtw/archive/2009/02/18/supertable-plugin-for-jquery.aspx 稍早發表了GridView 的標題列凍結效果&#xff0c;足以滿足工作上的需求&#xff0c;不過存在兩個缺點:…

psu是什么電腦配件_PSU的完整形式是什么?

psu是什么電腦配件PSU&#xff1a;電源部門/公共部門事業 (PSU: Power Supply Unit / Public Sector Undertaking) 1)PSU&#xff1a;電源設備 (1) PSU: Power Supply Unit) PSU is an abbreviation of the "Power Supply Unit". PSU是“電源設備”的縮寫 。 It is a…

【C++grammar】斷言與表達式常量

目錄1、常量表達式和constexpr關鍵字2、斷言與C11的靜態斷言1.1. assert : C語言的宏(Macro)&#xff0c;運行時檢測。1.2. assert()依賴于NDEBUG 宏1.3. assert 幫助調試解決邏輯bug &#xff08;部分替代“斷點/單步調試”&#xff09;2.1static_assert (C11的靜態斷言 )2.2.…

一些又用的國內著名期刊

記&#xff1a; 電子學報、電子與信息學報、圖像圖形學報、自動化學報、計算機學報、軟件學報、計算機研究與發展。轉載于:https://www.cnblogs.com/nanyangzp/p/3322244.html

一、Arduino UNO R3將數據上傳至云平臺

一、準備工作 ①ESP12E Shield ②Arduino UNO R3開發板 ③把ESP12E Shield安裝到Arduino UNO R3開發板上 ④登錄物聯網平臺注冊個賬號&#xff0c;到時候需要使用。 ⑤記錄下來你的Uid和key到時候會用到 ⑥創建個設備&#xff0c;用于測試 ⑦beyondyanyu為設備名&…

怎樣做一個快樂的ASP.NET程序員

首先我想解釋一下標題中兩個關鍵字: "快樂", "ASP.NET程序員". 有的人想成為一個"杰出"的程序員, 或者"資深"的程序員, 簡單來說就是"大牛"級的人物 -- 但是本文不是針對此種發展方向不是說我不鼓勵大家朝這方向走, 而是對我…

__eq___C ++'and_eq'關鍵字和示例

__eq__"and_eq" is an inbuilt keyword that has been around since at least C98. It is an alternative to & (Bitwise AND Assignment) operator and it mostly uses for bit manipulations. “ and_eq”是一個內置關鍵字&#xff0c;至少從C 98起就存在。 它…

leetcode 93. 復原IP地址 思考分析

題目 給定一個只包含數字的字符串&#xff0c;復原它并返回所有可能的 IP 地址格式。 有效的 IP 地址 正好由四個整數&#xff08;每個整數位于 0 到 255之間組成&#xff0c;且不能含有前導 0&#xff09;&#xff0c;整數之間用 ‘.’ 分隔。 例如&#xff1a;“0.1.2.201” …