Tutorial by Examples

For null check in method Object nullableObject = methodReturnObject(); if (Objects.isNull(nullableObject)) { return; } For not null check in method Object nullableObject = methodReturnObject(); if (Objects.nonNull(nullableObject)) { return; }
In the old fashion way for collection null check List<Object> someObjects = methodGetList(); for (Object obj : someObjects) { if (obj == null) { continue; } doSomething(obj); } With the Objects.nonNull method and Java8 Stream API, we can do the above in this way: ...

Page 1 of 1