I made a code
public class Test
{
public static void main(String[] args) throws InterruptedException, Exception
{
int[] VALID_SATES = { 8132, 33, 8988, 1740 };
int currentState = 331;
boolean valid = checkInArray(currentState, VALID_SATES);
if (valid)
{
System.out.print("Value in Array");
}
else
{
System.out.print("Value Not In Array");
}
}
private static boolean checkInArray(int currentState, int[] myArray)
{
for (int i : myArray )
{
if (i == currentState)
{
return true;
}
}
return false;
}
}
I am new to java, so not sure if there an easy way to do this ?

New Topic/Question
Reply



MultiQuote






|