Skip to content

Instantly share code, notes, and snippets.

@SamuelSchwent
Last active March 3, 2016 15:28
Show Gist options
  • Select an option

  • Save SamuelSchwent/3c96e5b436cb663a6c25 to your computer and use it in GitHub Desktop.

Select an option

Save SamuelSchwent/3c96e5b436cb663a6c25 to your computer and use it in GitHub Desktop.
Java - Arrays and Sort Example
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;
}
}
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