How to find Two digit element in this Array int[] abc= {2,1,3,44,52,23}; using For-Loop.

 Interview Question?

 Now Out of this Array  int[]  abc = {2,1,3,44,52,23}; I want you to write a Logic to print only number having 2 digits using for Loop.

Solution :

package p3;

public class ArrayTwoDigitCount {

public static void main(String[] args) {
int[] abc= {2,1,3,44,52,23};
for(int i: abc) {
if(i>=10 && i<=99) {
System.out.println("Two-digit-elements :"+i);
}
}

}

}

****************************************************************
O/P:

Two-digit-elements :44
Two-digit-elements :52
Two-digit-elements :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?