From 636c2f8f561f4f85fa9fd91a47e7abdb6f7f4069 Mon Sep 17 00:00:00 2001 From: Ajantha Wijerathna <45414044+Ajantha8@users.noreply.github.com> Date: Mon, 5 Oct 2020 13:37:40 +0530 Subject: [PATCH] Create BubbleSort.java --- Algorithm/BubbleSort.java | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 Algorithm/BubbleSort.java diff --git a/Algorithm/BubbleSort.java b/Algorithm/BubbleSort.java new file mode 100644 index 0000000..96c7a98 --- /dev/null +++ b/Algorithm/BubbleSort.java @@ -0,0 +1,29 @@ +public class BubbleSort { + + public static void main(String[] args) { + + int[] input = {10, 9, 7, 101, 23, 44, 12, 78, 34, 23}; + + for (int i = 0; i < 10; i++) { + + for (int j = 0; j < 10; j++) { + + if (input[i] < input[j]) { + int temp = input[i]; + input[i] = input[j]; + input[j] = temp; + } + + } + + } + + System.out.println("Bubble Sort : Sorted List"); + + for (int i = 0; i < 10; i++) { + System.out.println(input[i]); + } + + } + +}