/** * is collected in many ways in list. The Add (int index,object obj) method is not easily distinguishable from the set (int index,object e) method *. Through the following instances. Can see the difference between the two methods */package gao;import java.util.iterator;import Java.util.linkedlist;import Java.util.list;public class Collectiondemo {public static void main (string []args) { string a= "a", b= "B", c= "C", d= "D", e= "E"; List<string>list=new linkedlist<string> (); List.add (a); List.add (e); List.add (d); Iterator<string>first=list.iterator (); SYSTEM.OUT.PRINTLN ("The element in the collection before the change is:"); while (First.hasnext ()) { System.out.print (First.next () + ""); } List.set (1, b); List.add (2,c); Iterator second=list.iterator (); SYSTEM.OUT.PRINTLN ("The element after the change of the collection is:"); while (Second.hasnext ()) { System.out.print (Second.next () + "");}}}
watermark/2/text/ahr0cdovl2jsb2cuy3nkbi5uzxqvz3vhbmp1bmdhbw==/font/5a6l5l2t/fontsize/400/fill/i0jbqkfcma==/ Dissolve/70/gravity/southeast ">
Copyright notice: This article blog original articles, blogs, without consent, may not be reproduced.
Add and set difference method for Java learning list