Sort an ArrayList JAVA | Sololearn: Learn to code for FREE!

+2

Sort an ArrayList JAVA

Hi! I need help with sorting ArrayList with foreach loop: https://code.sololearn.com/chjjRqCXgo0n Also, how to display 5th element in the sorted list, delete the state at index 6 and identify which state was removed. Any help is much appreciated!

2/8/2018 10:47:21 PM

DIY Mods

1 Answer

New Answer

+12

U can use "Arrays.sort (arrayname);" to sort the array & then pickup 5 th element by writing arrarname[4]; & U can remove the content from at index 6th by writing arrayname [6]=""; &to identify , which state content was removed , U can run a loop & putting a if condition in it ... arrayname [a].equals ("") ... if thats evaluates to true ... means index a element's content was removed