This week's book giveaway is in the Design forum.
We're giving away four copies of Building Microservices and have Sam Newman on-line!
See this thread for details.
The moose likes Java in General and the fly likes Java - Collection of Objects Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Building Microservices this week in the Design forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Java - Collection of Objects" Watch "Java - Collection of Objects" New topic
Author

Java - Collection of Objects

sudha swami
Ranch Hand

Joined: Apr 24, 2007
Posts: 186
Hi,
I receive the object id(A5) from the client screen. I have collection of objects (A1 .. A10). I want object A5 to be the first object in the collection (A5,A1,A2,A3,A4,A6 ..A10). How to do this? Any help is appreciated.
regards
sudha
Zhia-zhia Xiu Bai
Greenhorn

Joined: Aug 29, 2007
Posts: 13
There are methods available like this one for an ArrayList(I don't know what kind of collection you are using):
add(index, Object)
which you can use in this case as add(0, A5).
This assumes you have gotten A5 off the request and built an ArrayList of your other objects.
Hope this helps.
 
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com
 
subject: Java - Collection of Objects
 
It's not a secret anymore!