How to remove specific object from ArrayList in Java?

前端 未结 13 1636
旧时难觅i
旧时难觅i 2020-12-05 06:54

How can I remove specific object from ArrayList? Suppose I have a class as below:

import java.util.ArrayList;    
public class ArrayTest {
    int i;

    pu         


        
13条回答
  •  無奈伤痛
    2020-12-05 07:34

    This helped me:

            card temperaryCardFour = theDeck.get(theDeck.size() - 1);
            theDeck.remove(temperaryCardFour);    
    

    instead of

    theDeck.remove(numberNeededRemoved);
    

    I got a removal conformation on the first snippet of code and an un removal conformation on the second.

    Try switching your code with the first snippet I think that is your problem.

    Nathan Nelson

提交回复
热议问题