public class ListTest {
/**
* @param args
*/
public static void main(String[] args) {
List array = new ArrayList();
array.add("a");
array.add("b");
array.add("c");
array.add("d");
array.add("a");
int a_num = 0;
int b_num = 0;
int c_num = 0;
int d_num = 0;
Iterator it = array.iterator();
while(it.hasNext()){
String next = (String)it.next();
if("a".equals(next)){
a_num ++;
}else if("b".equals(next)){
b_num ++;
}else if("c".equals(next)){
c_num ++;
}else if("d".equals(next)){
d_num ++;
}
}
int code = array.hashCode();
System.out.println("a_num="+a_num);
System.out.println("b_num="+b_num);
System.out.println("c_num="+c_num);
System.out.println("d_num="+d_num);
System.out.println(code);
}
}
/**
* @param args
*/
public static void main(String[] args) {
List array = new ArrayList();
array.add("a");
array.add("b");
array.add("c");
array.add("d");
array.add("a");
int a_num = 0;
int b_num = 0;
int c_num = 0;
int d_num = 0;
Iterator it = array.iterator();
while(it.hasNext()){
String next = (String)it.next();
if("a".equals(next)){
a_num ++;
}else if("b".equals(next)){
b_num ++;
}else if("c".equals(next)){
c_num ++;
}else if("d".equals(next)){
d_num ++;
}
}
int code = array.hashCode();
System.out.println("a_num="+a_num);
System.out.println("b_num="+b_num);
System.out.println("c_num="+c_num);
System.out.println("d_num="+d_num);
System.out.println(code);
}
}