Is there a way to sort ints that are not in an array?
I know you can use sort(arrayList) type idea with an array but example…
If I have individual variables can a similar task be done? Example, if I have three numbers can I sort them so that they print from largest to smallest?
Thanks!
If your ArrayList holds objects, the type of those objects can implement Comparable so you can use Collections‘ sort method. If you want, you can convert an ArrayList to an array and sort it that way, but it doesn’t look like that’s what you want. Here’s a quick example using both methods: