Created
March 27, 2010 21:13
-
-
Save damog/346356 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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