超実用1 ArrayListチェーンテーブル
8414 ワード
1 package ArrayList ; 2 import java.util.*; 3 public class kk1 { 4
5 /**
6 * :Mr.Fan 7 * : ArrayList 8 */
9 public static void main(String[] args) { 10 // TODO Auto-generated method stub
11 ArrayList al=new ArrayList(); 12 System.out.println("al :"+al.size()); 13 Clerk clerk1=new Clerk(" ",50,1000); 14 Clerk clerk2=new Clerk(" ",45,1200); 15 Clerk clerk3=new Clerk(" ",45,1400); 16 al.add(clerk1); 17 al.add(clerk2); 18 al.add(clerk3); 19 System.out.println("al :"+al.size()); 20 for(int i=0;i<al.size();i++) 21 { 22 Clerk temp=(Clerk)al.get(i);// i ,
23 System.out.println(" ="+temp.getName()); 24 } 25 //
26 al.remove(1); 27 System.out.println("++++++++++++ ++++++++++++++++++"); 28 for(int i=0;i<al.size();i++) 29 { 30 Clerk temp=(Clerk)al.get(i);// i ,
31 System.out.println(" ="+temp.getName()); 32 } 33
34 } 35
36 } 37 class Clerk 38 { 39
40 private String name; 41 private int age; 42 private float sal; 43 public Clerk(String name,int age,float sal) 44 { 45 this.name=name; 46 this.age=age; 47 this.sal=sal; 48 } 49 public String getName() { 50 return name; 51 } 52 public void setName(String name) { 53 this.name = name; 54 } 55 public int getAge() { 56 return age; 57 } 58 public void setAge(int age) { 59 this.age = age; 60 } 61 public float getSal() { 62 return sal; 63 } 64 public void setSal(float sal) { 65 this.sal = sal; 66 } 67 }