Home > Back-end >  Stream flow inside the null pointer
Stream flow inside the null pointer

Time:05-01

List Collect=objects. Stream (). The map (Student: : getId). Collect (Collectors. ToList ());
To ask you, the method how to avoid null pointer
!Such as the back with the query, select * from table where id in (collect) is wrong

CodePudding user response:

List Collect=objects. Stream (). The filter (objects: : nonNull). The map (Student: : getId)
Filter (Objects: : nonNull). Collect (Collectors. ToList ());

CodePudding user response:

reference 1st floor biankobe24 response:
List Collect=objects. Stream (). The filter (objects: : nonNull). The map (Student: : getId)
Filter (Objects: : nonNull). Collect (Collectors. ToList ());
solved, is this a three layer circulation inside the

CodePudding user response:

The first filter is to filter the Student is not null, the second filter is the filter getId not null

CodePudding user response:

reference biankobe24 reply: 3/f
the first filter is to filter the Student is not null, the second filter is the filter getId not null

Oh, oh, or in a layer of a for loop, bosses have any backstepping lambada expression, such as calculation for back, convenient debug
  • Related