Objective: The task of determining whether the provided String is a part of one of the string elements in the list.
String userInput = "Detailed"
List<String> list = Arrays.asList("C - Consolidated",
"D - Detailed",
"P - Corp. Consolidated",
"N - No Statement",
"O - Corporate",
"S - Summary",
"Y - Mail Statement",
"M - Summary - store name",
"I - Summary - 1 page");
my expectation is
if userInput is not in List then throw new IllegalArgumentException("Invalid") I am looking for solution in Java. I tired using StreamApi and for each but nothing worked for me.