Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Main {
- public static void main(String[] args) {
- int[] values = {0, 6, 5, 4, 8, 7, 11, -5, 19, 2};
- System.out.println("smallest: " + smallest(values));
- }
- public static int smallest(int[] array) {
- int smallest = array[array.length - 1];
- for (int x = array.length - 1; x >= 0; x--) {
- for (int y = 0; y < array.length; y++) {
- if ((array[x] < array[y]) && (array[x] < smallest)) {
- smallest = array[x];
- }
- }
- }
- return smallest;
- }
- }
Add Comment
Please, Sign In to add comment