File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
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


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
 
 
subject: ArrayList Manipulation