单词:Quanlity :质量的意思。 Quantity :数量的意思。
Map接口 实现该接口的类有
Hashtable() :hash算法(混乱算法:索引快),特点:线程安全,单线程不要用,浪费资源。
HashMap() :hash算法。特点: 在多线程的程序或网络中,线程是不安全的。
TreeMap() : 适用于:排序。
Preoerties :—>配置文件。
遍历Map
方法1:classic
Set kset=map.KeySet() ;
Iterator it = kset . iterator() ;
While(it . hasNext()){
value=map . get(it . next) ;
}
方法2:最新式遍历方法
for(Map . Entry<K , V> en : cartMap . entrySet())
{
C+=en . getValue() . totalPrice() ;
}
Collection接口
Set接口继承自Collection接口 ,HashSet类和TreeSet类均实现了Set接口。
Set中的常用方法:
方法 | 说明 |
Object [] toArray() | 返回一个包含Set中所有元素的数组 |
int size() | 返回Set中的元素数 |
boolean add() | 向Set中添加元素 |
boolean isEmpty | 如果Set中不包含元素,则返回true |
DecimalFormat类
Java API为我们提供了DecimalFormat类,为我们解决十进制数字的格式化问题。
例:<%=new DecimalFormat(“0.00”).format(price) %>
集成体系
Collection接口 下 :List接口和Set接口 。
List接口下 :ArrayList类和LinkedList类。
Set接口下 :HashSet类和TreeSet类。
Map接口下 :Hashmap类和Properties类
客户端提示信息
200系列 :正常解释。
300系列 :正在跳转的页面。
400系列 :客户端出的异常。
500系列 :服务器端出的异常。
扩展学习:
在编写HTML中MyEclipse在乱跳,可以通过Aptana—>Editors—>HTML—>Code Asst—>全关掉。来减轻一下。(此为6.0解决方案)
路径问题:<%=request.getContextPath() %>/servlet/doBookSerlet?isbn=<%=c . getIsbn() %>
建在:servlet/doBookServlet.java
Map中的containsKey(String); :判断有没有指定的Key。
Table表格的另一种写法:
<table border=”1”>
<thead>
<tr>……</tr>
</thead>
<tbody>
<tr>………..</tr>
</tbody>
<tfoot>
<tr>………</tr>
</tfoot>
</table>
细边框样式的另一种写法:
<style type="text/css">
.tb {
border-collapse: collapse;
width: 800px;
margin: 0 auto;
}
.tb td {
border: solid 1px grey;
}
</style>