This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
When I run your code there are only two values out of place: 3 and 4. The 3 makes sense; you start both i and j at 1, thereby always ignoring location 0. If I let both start at 0 then only 4 is out of place. That is not coincidentally the last element when you start.
PLease find the bellow steps
1. For loop from 0 to end of size of loop(u should start with 0)
2. 2nd for loop that should start with the i+1 to end of loop.
3. them make the comparison between the elements of two loops.
I believe its not clear..
Look for each element in first loop you need to compare the elements of the array(thats what is the 2nd loop for) and then select the least element(by giving 'if' condition in the 2nd loop). Now you need set the least element in the 1st position and the 1st position element in the place of least element. When the two loops completes you get the sorted array.