For loop to search for word in string

后端 未结 4 1290
孤城傲影
孤城傲影 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:33

    Why not use an enum for suit, and add it to your Card class or something a bit more Object Oriented? You could even have an Abstract class card or an interface card which would let you add what ever logic was needed inside the Card instance itsself instead of iterating doing string comparisons.

    However: String.split(String regex) should work, just choose the appropriate regular expression.

提交回复
热议问题