Last active
May 22, 2018 01:12
-
-
Save ThanawatMas/641bcf7aaf4ddc63574dae9b5e6221d1 to your computer and use it in GitHub Desktop.
SolveByJava8Stream.java
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) { | |
roundList = roundList | |
.stream() | |
.filter(item -> !item.equals(newItem)) | |
.map(Object::toString) | |
.collect(toList()); | |
roundList.add(0, newItem); | |
} | |
@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