Question: Hello! I have a question, how would I search a string in an ArrayList? So if a player says /search [Keyword], it will look inside a custom ArrayList for the keywords. How would I do this?
Code (Java): String value = yourList.stream().filter(s -> s.equalsIgnoreCase("theSearchArgument")).findFirst().orElse(null); Java 8 Stream API Or if you just want to know if it's there, Code (Java): yourList.contains("String");
Do you want to know whether the list contains the specified element or at which (for example 1st, 4th, etc.) index is it or do you want to get another value based on what the keyword is?
Damn i need to read Java 8 new things, it has a lot of improvements i think. If i am not wrong, you could just get the args between 0 and 1 and check if it equalsignorecase to what you want.