Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

Map¡¢Set¡¢Iteratorµü´úÏê½âÓëJavaƽ̨µÄ¼¯ºÏ¿ò¼Ü

Map¡¢Set¡¢Iteratorµü´úÏê½â
Map½Ó¿Ú¶¨ÒåÁËËÄÖÖÀàÐ͵ķ½·¨£¬Ã¿¸öMap¶¼°üº¬ÕâЩ·½·¨¡£
equals(Object o)±È½ÏÖ¸¶¨¶ÔÏóÓë´ËMapµÄµÈ¼ÛÐÔ¡£
hashCode()·µ»Ø´ËMapµÄ¹þÏ£Âë¡£
Map¶¨ÒåÁ˼¸¸öÓÃÓÚ²å·ÅºÍɾ³ýÔªËصı任·½·¨¡£
remove(Object key) ´ÓMapÖÐɾ³ý¼üºÍ¹ØÁªµÄÖµ¡£
put(object key,Object value) ½«Ö¸¶¨ÖµÓëÖ¸¶¨¼üÏà¹ØÁª¡£
clear() ´ÓMapËäɾ³ýËùÓÐÓ³Éä¡£
putAll(Map t) ½«Ö¸¶¨MapÖеÄËùÓÐÓ³É临ÖƵ½´ËMap¡£
²é¿´Map
µü´úMapÖеÄÔªËز»´æÔÚÖ±½ÓÁ˵±µÄ·½·¨¡£¼ÙÈçÒª²éѯij¸öMapÒÔÁ˽âÆäÄÄЩԪËØÂú×ãÌض¨²éѯ»ò¼ÙÈçÒªµü´úÆäËùÓÐÔªËØ£¬ÔòÄúÊ×ÏÈÐèÒª»ñÈ¡¸Ã
MapµÄ“ÊÓͼ”¡£ÓÐÈýÖÖ¿ÉÄܵÄÊÓͼ£ºËùÓмüÖµ¶Ô¡¢ËùÓмü¡¢ËùÓÐÖµ¡£Ç°Á½¸öÊÓͼ¾ù·µ»ØSet¶ÔÏ󣬵ÚÈý¸öÊÓͼ·µ»ØCollection¶ÔÏó¡£¾ÍÕâÁ½ÖÖ
Çé¿ö¶øÑÔ£¬ÎÊÌâµ½ÕâÀﲢûÓнáÊø£¬ÕâÊÇÒòΪÄúÎÞ·¨Ö±½Óµü´úCollection¶ÔÏó»òSet¶ÔÏó¡£Òª½øÐеü´ú£¬Äú±ØÐë»ñµÃÒ»¸öIterator¶ÔÏó¡£Òò´ËÒª
µü´úMapµÄÔªËØ£¬±ØÐë½øÐÐÈçϱàÂ룺
Iterator keyValuePairs = aMap.entrySet().iterator();
Iterator keys=aMap.keySet().iterator();
Iterator values=aMap.values().iterator();
ÖµµÃ×¢ÒâµÄÊÇ£¬ÕâЩ¶ÔÏóʵ¼ÊÉÏÊÇ»ù´¡MapµÄÊÓͼ£¬¶ø²»ÊÇ°üº¬ËùÓÐÔªËصĸ±±¾¡£
ʹÓÃIterator¶ÔÏó£¬Äú¿ÉÒÔ±éÀúMapµÄÔªËØ£¬»¹¿ÉÒÔɾ³ýMapÖеÄÔªËØ¡£
EnterySet()·µ»ØMapÖÐËù°üº¬Ó³ÉäµÄSetÊÓͼ¡£SetÖеÄÿ¸öÔªËض¼ÊÇÒ»¸öMap.Entry¶ÔÏ󣬿ÉÒÔʹÓÃgetKey()ºÍgetValue()·½·¨·ÃÎʺóÕߵļüÔª
ËغÍÖµÔªËØ¡£
keySet(£©·µ»ØMapÖÐËù°üº¬¼üµÄSetÊÓͼ¡£É¾³ýSetÖеÄÔªËØ»¹½«É¾³ýMapÖÐÏàÓ¦Ô­Ó³Éä¡£
values()·µ»ØMapÖÐËù°üº¬ÖµµÄCollectionÊÓͼ¡£É¾³ýCollectionÖеÄÔªËØ»¹½«É¾³ýMapÖÐÏàÓ¦µÄÓ³Éä
Map·ÃÎʺͲâÊÔ·½·¨£º
get(Object key) ·µ»ØÓëÖ¸¶¨¼ü¹ØÁªµÄÖµ
containsKey(Object key) ¼ÙÈçMap°üº¬Ö¸¶¨¼üµÄÓ³É䣬Ôò·µ»ØTrue
isEmpty() ¼ÙÈçMap²»°üº¬¼ü£­ÖµÓ³É䣬Ôò·µ»ØTrue
size() ·µ»ØMapÖеļüÖµÓ³ÉäµÄÊýÄ¿¡£
Set(interface)£º´æÈëSetµÄÿ¸öÔªËرØÐëÊÇΨһµÄ£¬ÒòΪSet²»±£´æÖظ´ÔªËØ¡£¼ÓÈëSetµÄObject±ØÐ붨Òåequals()·½·¨ÒÔÈ·±£¶ÔÏóµÄΨһÐÔ¡£
SetÓëCollectionÓÐÍêÈ«Ò»ÑùµÄ½Ó¿Ú¡£Set½Ó¿Ú²»±£Ö¤Î¬»¤ÔªËصĴÎÐò¡£
µü´úÆ÷ÊÇÒ»ÖÖÉè¼Æģʽ£¬ËüÊÇÒ»¸ö¶ÔÏó£¬Ëü¿ÉÒÔ±éÀú²¢Ñ¡ÔñÐòÁÐÖеĶÔÏ󣬶ø¿ªÈËÔ±²»ÐèÒªÁ˽â¸ÃÐòÁеĵײã½á¹¹¡£µü´úÆ÷ͨ³£±»³ÆΪ“ÇáÁ¿
¼¶”¶ÔÏó£¬ÒòΪ´´½¨ËüµÄ´ú¼ÛС¡£
JavaÖеÄIterator¹¦ÄܱȽϼòµ¥£¬²¢Ç


Ïà¹ØÎĵµ£º

JavaÖÐ×Ö·û´®ÓëASCIIÏ໥ת»»


import java.io.UnsupportedEncodingException;
public class T {
 public static void main(String[] args) throws UnsupportedEncodingException {
  t1();//ASCIIת»»Îª×Ö·û´®
  t2();//×Ö·û´®×ª»»ÎªASCIIÂë
 }
 public static void t1(){//ASCIIת»»Îª×Ö·û´®
   ......

ÓÃjava¶ÁÎļþÄÚÈÝ

import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.RandomAccessFile;
import java.io.Reader;
/**
 *
 * ¶àÖÖ·½Ê½¶ÁÎ ......

JAVA½«ÄÚÈÝ×·¼Óµ½Îļþβ²¿

import java.io.FileWriter;
import java.io.IOException;
import java.io.RandomAccessFile;
/**
 * ½«ÄÚÈÝ×·¼Óµ½Îļþβ²¿
 */
public class AppendToFile
{
    /**
     * A·½·¨×·¼ÓÎļþ£ºÊ¹ÓÃRandomAccessFile
     *
    ......

Java AnnotationʹÓôóÈ« (ZT)


Ò»¡¢Annotation¾¿¾¹ÊÇʲô£¿
    Annotation ÌṩÁËÒ»ÌõÓë³ÌÐòÔªËعØÁªÈκÎÐÅÏ¢»òÕßÈκÎÔªÊý¾Ý£¨metadata£©µÄ;¾¶¡£´ÓijЩ·½Ãæ¿´£¬annotation¾ÍÏñÐÞÊηûÒ»Ñù±»Ê¹Ó㬲¢Ó¦ÓÃÓÚ°ü¡¢ÀàÐÍ¡¢¹¹Ôì·½·¨¡¢·½·¨¡¢³ÉÔ±±äÁ¿¡¢²ÎÊý¡¢±¾µØ±äÁ¿µÄÉùÃ÷ÖС£ÕâЩÐÅÏ¢±»´æ´¢ÔÚannotationµÄ“name=value”½á¹¹¶ÔÖÐ ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ