学习零件价格求和小程序心得:
1.养成好习惯,编写java程序之前建一个包
package com.zjs;
2.有关ArrayList动态数组的知识:
List list=new ArrayList();
有关函数:
list.add();
list.remove();
......
使用Iterator遍历:
Iterator it=list.iterator();
while(it.hasNext()){
cost+=((Conponent)it.next()).cost();
}
普通方法遍历:
for(int i=0;i<list.size();i++){
Component c=(Component)list.get(i);
}
3.使用Vector遍历:
Vector a=new Vector();
Enumeration enum=a.elements();
while(enum.hasMoreElements()){
cost+=((Component)enum.nextElement()).cost();
}