Meaningless Drivel is fun!*
The moose likes Beginning Java and the fly likes ArrayList Manipulation Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "ArrayList Manipulation" Watch "ArrayList Manipulation" New topic
Author

ArrayList Manipulation

Dave DiRito
Ranch Hand

Joined: Feb 08, 2008
Posts: 77
For this problem I need to find the smallest integer in an ArrayList and move it to the front of the list without changing the order of the other list elements. I created the code to find the smallest value. I just can't figure out how to move it to the front of the list. Here's my code so far:
Garrett Rowe
Ranch Hand

Joined: Jan 17, 2006
Posts: 1296
So you know what index in the ArrayList the smallest element occupies right? So the next step is to remove it and add it at the first index in the ArrayList.


Some problems are so complex that you have to be highly intelligent and well informed just to be undecided about them. - Laurence J. Peter
Dave DiRito
Ranch Hand

Joined: Feb 08, 2008
Posts: 77
Thanks again, Garrett. I was making it way harder than necessary. Now it seems so obvious.

Thank you,
Dave
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: ArrayList Manipulation
 
Similar Threads
min max array list
need help sorting Integer objects
OutOfMemoryError: Java Heap Space
; expected
How to find the smallest element in an array?