Last active
May 22, 2018 01:12
-
-
Save ThanawatMas/e3453fe0c258a416976e6511811abf98 to your computer and use it in GitHub Desktop.
SolveByJava8Stream Check Value
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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