forked from ironhack-labs/lab-java-basics-es
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMain.java
More file actions
21 lines (17 loc) · 656 Bytes
/
Main.java
File metadata and controls
21 lines (17 loc) · 656 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
public class Main {
public static void main(String[] args) {
int[] array = {8, 12, 23, 31, 14};
int pequeño = Integer.MAX_VALUE;
int masPequeño = Integer.MAX_VALUE;
for (int i = 0; i < array.length; i++) {
if (array[i] < pequeño) {
masPequeño = pequeño;
pequeño = array[i];
} else if (array[i] < masPequeño && array[i] != pequeño) {
masPequeño = array[i];
}
}
System.out.println("El número más pequeño es: " + pequeño);
System.out.println("El segundo más pequeño es: " + masPequeño);
}
}