java Map ±éÀúËÙ¶È×îÓŽâ
java Map ±éÀúËÙ¶È×îÓŽâ
µÚÒ»ÖÖ:
Map map = new HashMap();
Iterator iter = map.entrySet().iterator();
while (iter.hasNext()) {
Map.Entry entry = (Map.Entry) iter.next();
Object key = entry.getKey();
Object val = entry.getValue();
}
ЧÂʸß,ÒÔºóÒ»¶¨ÒªÊ¹ÓôËÖÖ·½Ê½£¡
µÚ¶þÖÖ:
Map map = new HashMap();
Iterator iter = map.keySet().iterator();
while (iter.hasNext()) {
Object key = iter.next();
Object val = map.get(key);
}
ЧÂʵÍ,ÒÔºó¾¡Á¿ÉÙʹÓã¡
HashMapµÄ±éÀúÓÐÁ½ÖÖ³£Óõķ½·¨£¬ÄǾÍÊÇʹÓÃkeyset¼°entrysetÀ´½øÐбéÀú£¬µ«Á½ÕߵıéÀúËÙ¶ÈÊÇÓвî±ðµÄ£¬ÏÂÃæÇ뿴ʵÀý£º
public class HashMapTest {
public static void main(String[] args) ...{
HashMap hashmap = new HashMap();
for (int i = 0; i < 1000; i ) ...{
hashmap.put("" i, "thanks");
}
long bs = Calendar.getInstance().getTimeInMillis();
Iterator iterator = hashmap.keySet().iterator();
while (iterator.hasNext()) ...{
System.out.print(hashmap.get(iterator.next()));
}
System.out.println();
System.out.println(Calendar.getInstance().getTimeInMillis() - bs);
listHashMap();
}
public static void listHashMap() ...{
java.util.HashMap hashmap = new java.util.HashMap();
for (int i = 0; i < 1000; i ) ...{
hashmap.put("" i, "thanks");
}
long bs = Calendar.getInstance().getTimeInMillis();
java.util.Iterator it = hashmap.entrySet().iterator();
while (it.hasNext()) ...{
java.util.Map.Entry entry = (java.util.Map.Entry) it.next();
// entry.getKey() ·µ»ØÓë´ËÏî¶ÔÓ¦µÄ¼ü
// entry.getValue() ·µ»ØÓë´ËÏî¶ÔÓ¦µÄÖµ
System.out.print(entry.getValue());
}
System.out.println();
System.out.println(Calendar.getInstance().getTimeInMillis() - bs);
}
}
¶ÔÓÚkeySetÆäʵÊDZéÀúÁË2´Î£¬Ò»´ÎÊÇתΪiterator£¬Ò»´Î¾Í´ÓhashmapÖÐÈ¡³ökeyËù¶ÔÓÚµÄvalue¡£¶øentrysetÖ»ÊDZéÀúÁ˵ÚÒ»´Î£¬Ëû°ÑkeyºÍvalue¶¼·Åµ½ÁËentryÖУ¬ËùÒԾͿìÁË¡£
×¢:HashtableµÄ±éÀú·½·¨ºÍÒÔÉϵIJ¶à£¡
Ïà¹ØÎĵµ£º
/**
* check if the odivalue has a legal version format[0.0.0.0]
* @param odivalue:The odivalue extracted from SOAP
* @return :a boolean value,true or false
*/
public static boolean isCorrectVersion(String odivalue) {
// TODO Auto-generated method stub
Pattern pattern = Patter ......
Ê×ÏȾͱêÌâ˵Ã÷Ò»µã£¬javaʹÓÃorg.apache.commons.net.ftp.ftpclient°üÀ´²Ù×÷FTPÊǺÜˬµÎ£¬µ«¶ÔÔ¶³ÌÎļþ²Ù×÷£¬ºÃÏñûÓÐʵÏÖ
¸´ÖÆÎļþµÄ·½·¨¡£ÎÒÓõÄÊÇÎļþÒƶ¯(move)£¬°ÑÎļþ´ÓÒ»¸öÎļþ¼ÐÒƶ¯µ½ÁíÍâÒ»¸öÎļþ¼Ð¡£
±³¾°£º
ÔÚactionÖвÙ×÷Ô¶³ÌFTP£¬ÊµÏÖÎļþÒƶ¯¡£³ÌÐòÔËÐÐÔÚ±¾»ú£¬FTPÊÇÒ»¸öLinux· ......
import java.net.url;
import java.sql.*;
public class javaoracle {
public javaoracle() {
}
public static void main(string[] args){
try
{
try{
class.forname("oracle.jdbc.driver.oracledriver");
}
catch(java.lang.classnotfoundexception e)
{
system.err.print(e.getmessage());
} ......
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.*;
import java.io.*;
import java.nio.CharBuffer;
public class RegTest
{
public static void main(String[] args)
{
//¶¨ÒåÒ»¸öÎÄÕÂÁÐ ......