Skip to content

Instantly share code, notes, and snippets.

@damog
Created March 27, 2010 21:13
Show Gist options
  • Save damog/346356 to your computer and use it in GitHub Desktop.
Save damog/346356 to your computer and use it in GitHub Desktop.
class OddityTest {
public static boolean isItOdd(int i) {
return i % 2 == 1;
}
public static boolean isItReallyOdd(int i) {
return i % 2 != 0;
}
public static void main(String[] args) {
int[] num = {-4, -3, -2, -1, 0 , 1, 2, 3, 4};
for(int i = 0; i < num.length; i++) {
System.out.println("testing... " + num[i]);
System.out.println("isItOdd..." + isItOdd(num[i]));
System.out.println("isItReallyOdd..." + isItReallyOdd(num[i]) + "\n");
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment