Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Arrays;
- import java.util.stream.Collectors;
- public class Driver {
- public static void main(String[] args) {
- int[] x = {3, 1, 5, 2, 4};
- int a = 0;
- for (int index = 0; index < x.length - 1; index++) {
- if (x[index] > x[index + 1]) {
- a = x[index];
- x[index] = x[index + 1];
- x[index + 1] = a;
- }
- }
- System.out.println("x = " + Arrays.stream(x).boxed().collect(Collectors.toList()));
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement