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

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 ?