• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Java - Collection of Objects

 
sudha swami
Ranch Hand
Posts: 186
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 13
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic