Skip to content

Instantly share code, notes, and snippets.

@ThanawatMas
Last active May 22, 2018 01:12
Show Gist options
  • Save ThanawatMas/e3453fe0c258a416976e6511811abf98 to your computer and use it in GitHub Desktop.
Save ThanawatMas/e3453fe0c258a416976e6511811abf98 to your computer and use it in GitHub Desktop.
SolveByJava8Stream Check Value
import static java.util.stream.Collectors.toList;
public class SolveByJava8Stream extends ConcurrentModificationSolution {
@Override
public void addItemAndReIndex(List<String> roundList, String newItem) {
System.out.println("Before roundListIdentity=" + System.identityHashCode(roundList));
roundList = roundList
.stream()
.filter(item -> !item.equals(newItem))
.map(Object::toString)
.collect(toList());
roundList.add(0, newItem);
System.out.println("Result : " + roundList);
System.out.println("After roundListIdentity=" + System.identityHashCode(roundList));
}
@Override
public String solutionName() {
return "Java8 Stream";
}
public static void main(String[] args) {
SolveByJava8Stream java8Stream = new SolveByJava8Stream();
java8Stream.solve();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment