1 PackageArrayList linked list;2 ImportJava.util.*;3 Public classKK1 {4 5 /**6 * Mr.fan7 * Function: Remember ArrayList linked list8 */9 Public Static voidMain (string[] args) {Ten //TODO auto-generated Method Stub OneArrayList al=NewArrayList (); ASystem.out.println ("Al size:" +al.size ()); -Clerk clerk1=NewClerk ("Song Jiang", 50,1000); -Clerk Clerk2=NewClerk ("Wu use", 45,1200); theClerk clerk3=NewClerk ("Lin", 45,1400); - Al.add (CLERK1); - Al.add (CLERK2); - Al.add (CLERK3); +System.out.println ("Al size:" +al.size ()); - for(intI=0;i<al.size (); i++) + { AClerk temp= (Clerk) Al.get (i);//Here I refers to the address in the linked list, pointing to the atSystem.out.println ("name =" +temp.getname ()); - } - //Delete an object -Al.remove (1); -System.out.println ("++++++++++++ delete Wu with ++++++++++++++++++"); - for(intI=0;i<al.size (); i++) in { -Clerk temp= (Clerk) Al.get (i);//Here I refers to the address in the linked list, pointing to the toSystem.out.println ("name =" +temp.getname ()); + } - the } * $ }Panax Notoginseng classClerk - { the + PrivateString name; A Private intAge ; the Private floatSal; + PublicClerk (String name,intAgefloatSal) - { $ This. name=name; $ This. age=Age ; - This. sal=Sal; - } the PublicString GetName () { - returnname;Wuyi } the Public voidsetName (String name) { - This. Name =name; Wu } - Public intGetage () { About returnAge ; $ } - Public voidSetage (intAge ) { - This. Age =Age ; - } A Public floatgetsal () { + returnSal; the } - Public voidSetsal (floatSal) { $ This. Sal =Sal; the } the}
Super Utility 1 ArrayList linked list