Get the App
SLTechnology News&Howtos  ›  Development  › 

How to remove the value of the specified condition in list

Shulou Source: shulou.com Published: 2022-06-02 05:44:37 09月26日 Update

This article focuses on "how to remove the value of the specified condition in list". Interested friends may wish to take a look. The method introduced in this paper is simple, fast and practical. Let the editor take you to learn "how to remove the value of the specified condition in list"!

Remove the value of the specified condition in list under the condition that new objects are not allowed

one

two

three

four

five

six

seven

eight

nine

ten

eleven

twelve

thirteen

fourteen

fifteen

sixteen

seventeen

eighteen

nineteen

twenty

twenty-one

twenty-two

twenty-three

twenty-four

twenty-five

twenty-six

twenty-seven

twenty-eight

twenty-nine

thirty

thirty-one

thirty-two

thirty-three

thirty-four

thirty-five

thirty-six

thirty-seven

thirty-eight

thirty-nine

forty

forty-one

forty-two

forty-three

forty-four

forty-five

forty-six

forty-seven

forty-eight

forty-nine

fifty

fifty-one

Package com.liujianwang.learning

Import java.util.LinkedList

Import java.util.List

Public class ListTest {

Public static void main (String [] args) {

/ *

* remove the value of the specified condition in list if new objects are not allowed.

* for example: remove elements with a value greater than 6 in list.

, /

/ / Test data

List list = new LinkedList ()

For (int I = 0; I 6) {

List.remove (I)

IMurray-

}

}

}

/ * *

* Scheme 2: reverse order processing to avoid indexing problems.

, /

Private static void removeListDesc (List list) {

For (int I = (list.size ()-1); I > = 0; imuri -) {

If (list.get (I) > 6) {

List.remove (I)

}

}

}

}

At this point, I believe you have a deeper understanding of "how to remove the value of the specified condition in list". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!

Tags: Condition middle finger scheme index problem reverse order content object processing learning practicality deeper median element interest practicality practicality simple operation data method Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Apple Xiaomi Shulou Technology MariaDB Redmi