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

What are POJO classes in spring? What is the use of POJO Class, and How to create POJO classes.

How to create React project using command prompt?