Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Sorting arraylists in java
#1
I'm trying to create a method that sorts out a certain attribute of an object in an arraylist and print out the objects containing this attribute. Anyone know of a way to do this?
Reply
#2
for each object in arraylist {
if object has attribute{
print object

So basically you're using a loop to iterate through each element in the array, and printing it if it has the attribute. Does that help at all?
(2016-04-09 18:31:49)dotime Wrote: clam down
Reply
#3
Use a Comparator, then you can use the standard sort method that uses that comparator.
I don't have a sicknature
YouTube (original music) | Newgrounds (games)
Reply
#4
Are you sorting entities in an array or pulling data out from an array? I'm a bit confused here.
Reply




Users browsing this thread: 1 Guest(s)