For loop to search for word in string

后端 未结 4 1240
孤城傲影
孤城傲影 2021-01-18 11:12

I can\'t seem to find the syntax needed for the for loop in this method. I am looking to iterate through the words in the string suit.

EDIT: one thing t

4条回答
  •  北恋
    北恋 (楼主)
    2021-01-18 11:23

    If all you want to do is replace the strings that contain "SPADES":

    public String getSuit(int card){
        String suit = cardArray.get(card);
        if (suit.contains("SPADES")){
            cardArray.set(card, "SPADES");            
        }
        return suit;
    }
    

    If you want to split the string suit for some other reason then see the other answers

提交回复
热议问题