I've been playing around with ArrayList
s. What I'm trying to achieve is a method to do something like this:
Item 1
Item 2
Item 3
Item 4
I'm trying to be able to move items up in the list, unless it is already at the top in which case it will stay the same. For example, if item 3 was moved the list would be:
Item 1
Item 3
Item 2
Item 4
From my small understanding at the moment then I would want something along the lines of:
IF arrayname index is not equal to 0
THEN move up
ELSE do nothing
The part I'm struggling with is the "move up" part. Any tips or code samples of how this could be achieved are much appreciated.
Question&Answers:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…