Untitled
unknown
plain_text
2 years ago
588 B
2
Indexable
Never
public class LoopSmallestToLargeValue { public static void main(String[] args) { int numbers[] = {12, 6, 9, -1, 0, 8}; int smallest = numbers[0]; int biggest = numbers[0]; for (int i = 0; i < numbers.length; i++) { if (numbers[i] < smallest) { smallest = numbers[i]; } if (numbers[i] > biggest) { biggest = numbers[i]; } } System.out.println("Smallest: " + smallest); System.out.println("Largest: " + biggest); } }