Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Sorting arraylists in java
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?
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
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)
Are you sorting entities in an array or pulling data out from an array? I'm a bit confused here.

Users browsing this thread: 1 Guest(s)