Java Stream列表操作

时间:2017-07-17 06:44:43

标签: java list java-8 java-stream

拥有Option Explicit Private Declare Sub keybd_event Lib "user32" (ByVal bVk As Byte, ByVal _ bScan As Byte, ByVal dwFlags As Long, ByVal dwExtraInfo As Long) Private Const KEYEVENTF_KEYUP = &H2 Private Const VK_SNAPSHOT = &H2C Private Const VK_MENU = &H12 Sub AltPrintScreen() keybd_event VK_MENU, 0, 0, 0 keybd_event VK_SNAPSHOT, 0, 0, 0 keybd_event VK_SNAPSHOT, 0, KEYEVENTF_KEYUP, 0 keybd_event VK_MENU, 0, KEYEVENTF_KEYUP, 0 End Sub ,其中List<SomeObject>在其他字段中包含日期字段。使用SomeObject寻找获取两个列表,一个包含日期字段非空的SomeObject实例,另一个包含剩余的具有空日期字段的SomeObject实例。

1 个答案:

答案 0 :(得分:3)

您正在寻找Collectors.partitioningBy

Map<Boolean,List<SomeObject>> partition =
    list.stream().collect(Collectors.partitioningBy(s->s.getDate()!=null));