博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
removerange_Java Vector removeRange()方法与示例
阅读量:2536 次
发布时间:2019-05-11

本文共 2145 字,大约阅读时间需要 7 分钟。

removerange

向量类别的removeRange()方法 (Vector Class removeRange() method)

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

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

  • removeRange() method is used to remove all the elements lies in between starting index (st_index) and ending index (en_index) and st_index is inclusive whereas en_index is exclusive.

    removeRange()方法用于删除起始索引(st_index)和结束索引(en_index)之间的所有元素,st_index为包含值,而en_index为排除值。

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

    removeRange()方法是一个非静态方法,只能通过类对象访问,如果尝试使用类名称访问该方法,则会收到错误消息。

  • removeRange() method does not throw an exception at the time of removing elements in a range.

    removeRange()方法在删除范围中的元素时不会引发异常。

Syntax:

句法:

public void removeRange(int st_index , int en_index);

Parameter(s):

参数:

  • int st_index – represents the starting endpoint to remove.

    int st_index –表示要删除的起始端点。

  • int en_index – represents the ending endpoint to remove.

    int en_index –表示要删除的结束端点。

Return value:

返回值:

The return type of the method is void, it returns nothing.

该方法的返回类型为void ,不返回任何内容。

Example:

例:

// Java program to demonstrate the example // of void removeRange(int st_index , int en_index)// method of Vector import java.util.*;public class RemoveRangeAtOfVector {
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"); v.add("PHP"); v.add("SFDC"); v.add("ANDROID"); // Display Vector System.out.println("v: " + v); // By using removeRange(3,5) method is // to remove the element in the given range // and removing element starts at index 3 // and ends at index 5 but 5th index is exclusive // its a protected method so we are using subList instead v.subList(3, 5).clear(); // Display updated vector System.out.println("v.removeRange(3,5): " + v); }}

Output

输出量

v: [C, C++, JAVA, PHP, SFDC, ANDROID]v.removeRange(3,5): [C, C++, JAVA, ANDROID]

翻译自:

removerange

转载地址:http://wsvzd.baihongyu.com/

你可能感兴趣的文章
Swift语言指南(一)--语言基础之常量和变量
查看>>
关于webpack的使用
查看>>
Windows 2008 R2上配置IIS7或IIS7.5中的URLRewrite(URL重写)实例
查看>>
浅析java垃圾回收机制
查看>>
彻底理解线性筛选法
查看>>
Java Socket总结
查看>>
法语学习笔记
查看>>
使用css的类名交集复合选择器 《转》
查看>>
[USACO18DEC]The Cow Gathering
查看>>
情感分析-英文电影评论
查看>>
王者荣耀游戏服务器架构的演进读后感
查看>>
关于ajax请求controller返回中文乱码的解决方法!
查看>>
Objective-C 和 Core Foundation 对象相互转换的内存管理总结
查看>>
IOS音频1:之采用四种方式播放音频文件(一)AudioToolbox AVFoundation OpenAL AUDIO QUEUE...
查看>>
Linux nmon 命令
查看>>
使用 urllib 构造请求对象
查看>>
sql server book
查看>>
长亭技术专栏 安全攻防技术分享
查看>>
sql server dba
查看>>
visualvm
查看>>