Don't know what's wrong with the code. It looks fine to me. I read about array and bubble sort on an another website and tried to implement it. But the code didn't ran as expected.
package com.codegym.task.task04.task0420;
/*
Sorting three numbers
*/
import java.io.*;
import java.util.*;
public class Solution {
public static void main(String[] args) throws Exception {
//write your code here
Scanner sc =new Scanner(System.in);
int a= sc.nextInt();
int b= sc.nextInt();
int c = sc.nextInt();
int[] arr = {a,b,c};
sorting(arr);
}
public static void sorting(int [] arr){
int n = arr.length();
int temp = 0;
for( int i=0; i<n; i++){
for(j=1; j<(n-i); j++){
if (arr[j]<arr[j-1]){
temp= arr[j];
arr[j]=arr[j-1];
arr[j-1]= arr[j];
}
}
for (int i=0; i<n; i++){
System.out.print(arr[i]+" ");
}
}
}
}