Is there any way to know if an arraylist contains a piece of text?

前端 未结 5 1421
执笔经年
执笔经年 2021-01-15 11:35

I have an arraylist with several items. Let\'s say they are: \"DARK BROWN\", \"BLUE\", \"GREEN\",....

Is there any way to look for if there\'s the string \"DARK\" in

5条回答
  •  有刺的猬
    2021-01-15 12:36

    Either do it like you have done it, or it gets much more complex. There is a search structure called "trie" , but this is complex.

    You could gain a bit by having an array of a- z pointing to the start position in your sorted ArrayList of the first letter. Then you only have to search within the words that start with the same letter.

提交回复
热议问题