My code is showing me a outof bound exception.. may you please help me with this code

this code is giving me all desired output when i dont use the if else blocks to print result in ascending order. but when i use this block it shows me an out of boundh exception in line no. 30. hows it possible to show and and output printing codes to show out of bound exception when they haven’t make any change with array.
please answer my doubt too

first of all no need to make a public class inside main class…you can directly write your code in main class…
in second for loop the condition should be j<arr.length-1…also print your output as specified in the ques…

also your codes complexity is n^3…try thinking of a n^2 soln