Collect the element in Set format
Set<String> finalString= list1.stream().filter(s -> s.contains("Test")).collect(
System.out.println(
------------------------------
Collect the element in List format
Method 1
List<String> finalString= list1.stream().filter(s -> s.contains("Test")).collect(
System.out.println(
Method2
List<String> finalString= list1.stream().filter(s -> s.contains("Test")).toList();
System.out.println(
------------------------------
No comments:
Post a Comment