Created
November 7, 2020 03:49
-
-
Save moqimoqidea/d98ce65902088bca7aaa4a6856be5449 to your computer and use it in GitHub Desktop.
Practice IntelliJ IDEA debugger by Example
This file contains 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 java.util.Arrays; | |
import java.util.List; | |
import java.util.Objects; | |
import java.util.Random; | |
/** | |
* 练习 IDEA Debugger 功能 | |
* <p> | |
* 练习: https://moqimoqidea.github.io/2017/06/02/IDEA-Debugger/ | |
* | |
* @author moqi On 10/15/20 16:22 | |
*/ | |
public class TestIDEADebugger { | |
public static void main(String[] args) { | |
// testException(); | |
// testReload(); | |
testJavaStream(); | |
} | |
private static int testException() { | |
return 10 / 0; | |
} | |
private static void testReload() { | |
int value = new Random().nextInt(1000); | |
System.out.println("value = " + value); | |
int doubleValue = getDoubleValue(value); | |
System.out.println("doubleValue = " + doubleValue); | |
} | |
private static int getDoubleValue(int i) { | |
return i * 2; | |
// return i * 100; | |
} | |
private static void testJavaStream() { | |
List<Integer> numberList = Arrays.asList(1, 1, null, 2, 3, 4, null, 5, 6, 7, 8, 9, 0); | |
System.out.println("sum is: " + | |
numberList.stream() | |
.filter(Objects::nonNull) | |
.distinct() | |
.mapToInt(num -> num * 2) | |
.peek(System.out::println) | |
.skip(2) | |
.limit(4) | |
.sum() | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment