java - Removing elements from ArrayList in ascending order -
I am trying to extract the elements in ArrayList in ascending order. I am down to descending order, but it can not understand it on the other side.
I have tried:
for (int r = 0; r But it only shows the elements and elements elements made from zero.
So far I have:
public class test {public static zero main (string) [] args) {Array list & lt; String & gt; s = new arreelist & lt; & Gt; (4); S.add ('a'); S.add ("b"); S.add ('c'); S.add ('d'); Removes elements in descending order for // (int r = s.size () - 1; r> = 0; r -) {System.out.println (s); S.remove (r); } System.out.println (s.size ()); }} Any ideas?
You can try this
array list & lt; String & gt; s = new ArrayList & lt; String & gt; (4); S.add ('a'); S.add ("b"); S.add ('c'); S.add ('d'); // Reverse the array list. Source (S, Collection. Raerserver ()); Iterator & LT; String & gt; I = s.iterator (); While (i.hasNext ()) {System.out.println (i.next ()); I remove(); }
Comments
Post a Comment