Skip to content

Instantly share code, notes, and snippets.

@moqimoqidea
Created November 7, 2020 03:49
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save moqimoqidea/d98ce65902088bca7aaa4a6856be5449 to your computer and use it in GitHub Desktop.
Save moqimoqidea/d98ce65902088bca7aaa4a6856be5449 to your computer and use it in GitHub Desktop.
Practice IntelliJ IDEA debugger by Example
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