import
java.io.*;
import
java.util.*;
import
java.util.stream.*;
class
GFG {
public
static
<T> ArrayList<T>
createArrayList(List<T> collection, T N)
{
ArrayList<T> list =
new
ArrayList<T>();
collection.stream()
.filter(item -> !item.equals(N))
.forEachOrdered(list::add);
return
list;
}
public
static
void
main(String[] args)
{
List<Integer> collection1
= Arrays.asList(
1
,
2
,
3
);
System.out.println(
"ArrayList with selected "
+
"elements of collection "
+ collection1 +
": "
+ createArrayList(collection1,
2
));
List<String> collection2
= Arrays.asList(
"GFG"
,
"Geeks"
,
"GeeksForGeeks"
);
System.out.println(
"ArrayList with selected "
+
"elements of collection "
+ collection2 +
": "
+ createArrayList(collection2,
"GFG"
));
}
}