I need to write a method that returns true if all the values in two int arrays are in the range 0-10, otherwise the method returns false. The code I have written is below but is there a better/more effient way to do this?
private int[] myArray1;
private int[] myArray2;
private boolean validNumbers()
{
for(int i = 0; i < myArray1; i++)
{
if(myArray1[i] < 0 || myArray1[i] > 9)
return false;
}
for(int i = 0; i < myArray2; i++)
{
if(myArray2[i] < 0 || myArray2[i] > 9)
return false;
}
return true;
}
Thanks