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
| public int streamMaxInteger() { | |
| Optional max = integers.stream().reduce(Integer::max); | |
| return max.get(); | |
| } |
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
| public int forEachLambdaMaxInteger() { | |
| final Wrapper wrapper = new Wrapper(); | |
| wrapper.inner = Integer.MIN_VALUE; | |
| integers.forEach(i -> helper(i, wrapper)); | |
| return wrapper.inner.intValue(); | |
| } | |
| public static class Wrapper { | |
| public Integer inner; |
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
| public int lambdaMaxInteger() { | |
| return integers.stream().reduce(Integer.MIN_VALUE, (a, b) -> Integer.max(a, b)); | |
| } |
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
| public int parallelStreamMaxInteger() { | |
| Optional max = integers.parallelStream().reduce(Integer::max); | |
| return max.get(); | |
| } |
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
| public int forMaxInteger() { | |
| int max = Integer.MIN_VALUE; | |
| for (int i = 0; i < size; i++) { | |
| max = Integer.max(max, integers.get(i)); | |
| } | |
| return max; | |
| } |
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
| public int forEachLoopMaxInteger() { | |
| int max = Integer.MIN_VALUE; | |
| for (Integer n: integers) { | |
| max = Integer.max(max, n); | |
| } | |
| return max; | |
| } |
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
| public int iteratorMaxInteger() { | |
| int max = Integer.MIN_VALUE; | |
| for (Iterator < Integer > it = integers.iterator(); it.hasNext();) { | |
| max = Integer.max(max, it.next()); | |
| } | |
| return max; | |
| } |
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
| logger.debug("This {} and {} with {}”, this, that, compute()); |
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
| if (logger.isDebugEnabled()) { | |
| logger.debug("This " + this + " and " + that + "with " + compute()); | |
| } |
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
| logger.debug("This " + this + " and " + that + "with " + compute()); |
NewerOlder