public class CheckIntArrayExample1
{
public int checkIntArrays(int[] inputArray)
{
int aryIndex;
int arySize = inputArray.length;
for(aryIndex = 0; aryIndex < arySize; aryIndex++)
{
if(inputArray[aryIndex] > 20)
{
return(aryIndex);
}
}
return(-1);
}
public void testArray(int array[])
{
// Print the array then test it.
System.out.print("Index of value > 20 for array {");
boolean firstTime = true;
for (int i=0; i
Index of value > 20 for array { 2, 4, 6, 8, 10, 12, 14, 16, 18, 20 }:-1 Index of value > 20 for array { 5, 10, 15, 20, 25 }:4 Index of value > 20 for array { 20, 40, 60, 80, 100 }:1
--- Output Ends ---
- javac CheckIntArrayExample1.java
- java CheckIntArrayExample1