I have List object and I need to take the first element on the list if it is not null or empty.
I write below code using java and now I want to convert it to Java 8.
List<DD> container
A<DD,DI> a;
if(container!=null || !container.isEmpty()){
for(DD dd:container)
{
a = dd.getPrescription();
break;
}
}
I convert it like this.
DD detail = container.stream().findFirst().get();
I need to know this is correct?