Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- import java.util.Arrays;
- public class Main {
- public static void main(String[] args) {
- Scanner sc = new Scanner(System.in);
- System.out.print("Type the length of the massive: ");
- int n = Integer.parseInt(sc.nextLine());
- int[] array = new int[n];
- for (int i = 0; i < n; i++) {
- System.out.print("Type number " + (i + 1) + ": ");
- array[i] = Integer.parseInt(sc.nextLine());
- }
- Arrays.sort(array);
- System.out.println("Second smallest element in the array is: " + array[1]);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement