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

Popular posts from this blog

How to create React project using command prompt?

How to achieve abstraction?

Interview Question? How to find square of each element in this Array {2,4,5,6,8} using map ?