-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMain.java
More file actions
27 lines (24 loc) · 812 Bytes
/
Copy pathMain.java
File metadata and controls
27 lines (24 loc) · 812 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
package com.company;
import java.util.InputMismatchException;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
int n = 0;
try (Scanner scan = new Scanner(System.in)) {
System.out.println("Write massive's length: ");
n = scan.nextInt();
Integer[]arr = new Integer[n];
for ( int i = 0; i < n; i++) {
System.out.println("Write next value: ");
arr[i] = scan.nextInt();
}
BubbleSorter.sort(arr);
System.out.print("Sorted array: ");
for (Integer i : arr ) {
System.out.print(i + " ");
}
} catch (InputMismatchException e) {
System.out.println("Wrong data type");
}
}
}