+ 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!
1 Respuesta
+ 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