Vs remove array elements

Source: Internet
Author: User

1. problems encountered in the project

How to remove elements from an array

The array itself does not remove elements.

Therefore, it is relatively inefficient to convert data into arraylist.

Method 1:

Method 2:

Then I came up with another method: Create an array and then filter out the elements you don't want from the original array of the for loop.

Method 3:

If the length of the array is not long and you know the size of the array

You can create an array as follows: the element whose subscript is 1 is deleted, that is, the second element.

String [] array2 = new string [7] {array [0], array [2], array [3], array [4], array [5], array [6], array [7],};

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.