java遍历对象
JDK1.4中
Map map = new HashMap();
Iterator it = map.entrySet().iterator();
while (it.hasNext()) {
Map.Entry entry = (Map.Entry) it.next();
Object key = entry.getKey();
Object value = entry.getValue();
}
JDK1.5中,应用新特性For-Each循环
Map m = new HashMap();
for(Object o : map.keySet()){
map.get(o);
}
返回的 set 中的每个元素都是一个 Map.Entry 类型。
private Hashtable<String, String> emails = new Hashtable<String, String>();
另外 我们可以先把hashMap 转为集合Collection,再迭代输出,不过得到的对象
//方法一: 用entrySet()
Iterator it = emails.entrySet().iterator();
while(it.hasNext()){
Map.Entry m=(Map.Entry)it.next();
logger.info("email-" + m.getKey() + ":" + m.getValue());
}
// 方法二:jdk1.5支持,用entrySet()和For-Each循环()
for (Map.Entry<String, String> m : emails.entrySet()) {
logger.info("email-" + m.getKey() + ":" + m.getValue());
}
// 方法三:用keySet()
Iterator it = emails.keySet().iterator();
while (it.hasNext()){
String key;
key=(String)it.next();
logger.info("email-" + key + ":" + emails.get(key));
}
// 方法五:jdk1.5支持,用keySEt()和For-Each循环
for(Object m: emails.keySet()){
logger.info("email-" + m+ ":" + emails.get(m));
}
Map aa = new HashMap();
aa.put("tmp1", new Object());
//追加 替换用同样的函数.
aa.remove("temp1");
//删除
for (Iterator i = aa.values().iterator
相关文档:
create PROCEDURE pagelist
@tablename nvarchar(50),
@fieldname nvarchar(50)='*',
@pagesize int output,--每页显示记录条数
@currentpage int output,--第几页
@orderid nvarchar(50),--主键排序
@sort int,--排序方式,1表示升序,0表示降序排列
......
一:准备 www.savarese.org download
1. rocksaw-1.0.0-src.tar.gz
2. vserv-tcpip-0.9.2-src.tar.gz
二:编译源文件得到jar包 使用Ant
1. build vserv-tcpip-0.9.2-src
在vserv-tcpip-0.9.2目录下面建一个tests目录,然后在cmd窗口下进入 ......
九 java面向对象程序设计(this关键字)
/**
* 面向对象之四
* this关键字总结
*/
/*this关键字的第一种用法*/
//在方法中调用同类中的方法,这时的this可以省略.
class ThisPointer
{
public void function1()
{
System.out.println("function1 is calling...");
......
使用ant.jar包(1.6版本),完成tar的打包功能,直接贴代码
import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Li ......
1、调用没有返回值和参数的Java方法
1.1、dwr.xml的配置
Xml代码
<dwr>
<allow>
<create creator="new" javascript="testClass" >
<param name="class" value="com.dwr.Test ......