How to find two-digit-elements using java8 stream?
Interview Question?
Now out of this Array int [] abc= {2,1,3,44,52,23} I want to write a Logic to print only number having 2 digits using java8.
Solution :
package p3;
import java.util.Arrays;
public class ArrayTwoDigitEleFound8 {
public static void main(String[] args) {
int[] abc= {2,1,3,44,52,23};
Arrays.stream(abc).filter(i->i>=10 && i<=100).forEach(System.out::println);
}
}
**********************************************************************
O/P : 44
52
23
Comments
Post a Comment