Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

I have been trying to implement Bubble Sort using simple integer array in java.

ID: 3537754 • Letter: I

Question

I have been trying to implement Bubble Sort using simple integer array in java. However there seems to be some problem. Now i know that using ArrayList would be the best option and I would do that too. But why isnt it getting sorted with simple integer array.Here is the code

Its producing the same array as entered. Nothing is getting changed. The difference between a simple array and an ArrayList or Vector ,is just that they offer dynamic time expansion of array size.Is there anything more to it? I mean does simple array creates a different instance every time it is manipulated, just like Strings? It does seem to do so here.

Explanation / Answer

Because you are creating two different BubbleSort Objects, sorting the first one and displaying a different one.

It should have been....

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote