Last active
March 3, 2016 15:28
-
-
Save SamuelSchwent/3c96e5b436cb663a6c25 to your computer and use it in GitHub Desktop.
Java - Arrays and Sort Example
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
| package Challenge4; | |
| public class LargerThan { | |
| public String displayLarger(int[] numbers, int n) | |
| { | |
| String largeNumbers = "Numbers greater than " + n + " are"; | |
| for(int x = 0; x < numbers.length; x++) | |
| { | |
| if (numbers[x] > n) | |
| largeNumbers += ", " + numbers[x]; | |
| } | |
| return largeNumbers; | |
| } | |
| } |
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
| package Challenge4; | |
| public class LargerThanDriver { | |
| public static void main(String[] args) { | |
| LargerThan test = new LargerThan(); | |
| int[] numbers = {4, 2, 88, 55, 45, 21, 67, 32, 1, 9, 100, 67}; | |
| int n = 54; | |
| System.out.println(test.displayLarger(numbers, n)); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment