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

Java¼¯ºÏÀàList/Set/MapµÄÇø±ðºÍÁªÏµ

 
Ò»¡¢Array £¬ Arrays
JavaËùÓГ´æ´¢¼°Ëæ»ú·ÃÎÊÒ»Á¬´®¶ÔÏó”µÄ×ö·¨£¬arrayÊÇ×îÓÐЧÂʵÄÒ»ÖÖ¡£
1¡¢
ЧÂʸߣ¬µ«ÈÝÁ¿¹Ì¶¨ÇÒÎÞ·¨¶¯Ì¬¸Ä±ä¡£
array»¹ÓÐÒ»¸öȱµãÊÇ£¬ÎÞ·¨ÅжÏÆäÖÐʵ¼Ê´æÓжàÉÙÔªËØ£¬lengthÖ»ÊǸæËßÎÒÃÇarrayµÄÈÝÁ¿¡£
2¡¢JavaÖÐÓÐÒ»¸öArraysÀ࣬רÃÅÓÃÀ´²Ù×÷array¡£
   
arraysÖÐÓµÓÐÒ»×éstaticº¯Êý£¬
equals()£º±È½ÏÁ½¸öarrayÊÇ·ñÏàµÈ¡£arrayÓµÓÐÏàͬԪËظöÊý£¬ÇÒËùÓжÔÓ¦ÔªËØÁ½Á½ÏàµÈ¡£
fill()£º½«ÖµÌîÈëarrayÖС£
sort()£ºÓÃÀ´¶Ôarray½øÐÐÅÅÐò¡£
binarySearch()£ºÔÚÅźÃÐòµÄarrayÖÐÑ°ÕÒÔªËØ¡£
System.arraycopy()£ºarrayµÄ¸´ÖÆ¡£
¶þ¡¢Collection £¬ Map
Èô׫д³ÌÐòʱ²»ÖªµÀ¾¿¾¹ÐèÒª¶àÉÙ¶ÔÏó£¬ÐèÒªÔڿռ䲻×ãʱ×Ô¶¯À©ÔöÈÝÁ¿£¬ÔòÐèҪʹÓÃÈÝÆ÷Àà¿â£¬array²»ÊÊÓá£
1¡¢Collection ºÍ Map µÄÇø±ð
ÈÝÆ÷ÄÚÿ¸öΪ֮Ëù´æ´¢µÄÔªËظöÊý²»Í¬¡£
CollectionÀàÐÍÕߣ¬Ã¿¸öλÖÃÖ»ÓÐÒ»¸öÔªËØ¡£
MapÀàÐÍÕߣ¬³ÖÓÐ key-value pair£¬Ïñ¸öСÐÍÊý¾Ý¿â¡£
2¡¢¸÷×ÔÆìϵÄ×ÓÀà¹Øϵ
Collection
   
--List£º½«ÒÔÌض¨´ÎÐò´æ´¢ÔªËØ¡£ËùÒÔÈ¡³öÀ´µÄ˳Ðò¿ÉÄܺͷÅÈë˳Ðò²»Í¬¡£
         
--ArrayList / LinkedList / Vector
    --Set £º
²»Äܺ¬ÓÐÖظ´µÄÔªËØ
         
--HashSet / TreeSet
Map
   
--HashMap
   
--HashTable
   
--TreeMap
3¡¢ÆäËûÌØÕ÷
* List£¬Set£¬Map½«³ÖÓжÔÏóÒ»ÂÉÊÓΪObjectÐͱð¡£
*
Collection¡¢List¡¢Set¡¢Map¶¼Êǽӿڣ¬²»ÄÜʵÀý»¯¡£
  
¼Ì³Ð×ÔËüÃÇµÄ ArrayList, Vector, HashTable, HashMapÊǾßÏóclass£¬ÕâЩ²Å¿É±»ÊµÀý»¯¡£
*
vectorÈÝÆ÷È·ÇÐÖªµÀËüËù³ÖÓеĶÔÏóÁ¥ÊôʲôÐͱð¡£vector²»½øÐб߽ç¼ì²é¡£
Èý¡¢Collections
CollectionsÊÇÕë¶Ô¼¯ºÏÀàµÄÒ»¸ö°ïÖúÀà¡£ÌṩÁËһϵÁо²Ì¬·½·¨ÊµÏÖ¶Ô¸÷ÖÖ¼¯ºÏµÄËÑË÷¡¢ÅÅÐò¡¢Ïß³ÌÍêÈ«»¯µÈ²Ù×÷¡£
Ï൱ÓÚ¶ÔArray½øÐÐÀàËƲÙ×÷µÄÀà——Arrays¡£
È磬Collections.max(Collection coll);
È¡collÖÐ×î´óµÄÔªËØ¡£
   
Collections.sort(List list); ¶ÔlistÖÐÔªËØÅÅÐò
ËÄ¡¢ÈçºÎÑ¡Ôñ£¿
1¡¢ÈÝÆ÷ÀàºÍArrayµÄÇø±ð¡¢ÔñÈ¡
   *
ÈÝÆ÷Àà½öÄܳÖÓжÔÏóÒýÓã¨Ö¸Ïò¶ÔÏóµÄÖ¸Õ룩£¬¶ø²»Êǽ«¶ÔÏóÐÅÏ¢copyÒ»·ÝÖÁÊýÁÐijλÖá


Ïà¹ØÎĵµ£º

Java NIO APIÏê½â

 
Java NIO APIÏê½â
ÔÚJDK
1.4ÒÔÇ°£¬JavaµÄIO²Ù×÷¼¯ÖÐÔÚjava.ioÕâ¸ö°üÖУ¬ÊÇ»ùÓÚÁ÷µÄ×èÈû£¨blocking£©API¡£¶ÔÓÚ´ó¶àÊýÓ¦ÓÃÀ´Ëµ£¬ÕâÑùµÄAPIʹÓúܷ½
±ã£¬È»¶ø£¬Ò»Ð©¶ÔÐÔÄÜÒªÇó½Ï¸ßµÄÓ¦Óã¬ÓÈÆäÊÇ·þÎñ¶ËÓ¦Óã¬ÍùÍùÐèÒªÒ»¸ö¸üΪÓÐЧµÄ·½Ê½À´´¦ÀíIO¡£´ÓJDK 1.4Æð£¬NIO
API×÷Ϊһ¸ö»ùÓÚ»º³åÇø£¬²¢ÄÜÌṩ·Ç×èÈû(non-blo ......

³õѧJAVAÖ®Èý

1¡¢±àдһ¸ö¼òµ¥µÄÎı¾±à¼­Æ÷£¬ÒªÇ󣺾ßÓдò¿ª¡¢±£´æ¡¢Ð½¨£¬Õ³Ìù¡¢¸´ÖƵȹ¦ÄÜ£»¾ßÓÐÒ»¸ö¹¤¾ßÌõ¡£
 
1.1¡¢³ÌÐòÔ´Â루²Î¼ûmenu.java£©£º
 
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.io.*;
import java.net.URL;
 
public class menu extends JFrame impl ......

JAVA±ÊÊÔÌâÑ¡ÔñÌâ

1ÏÂÃæÄĸöÊÇÕýÈ·µÄÀàÉùÃ÷£¿¼ÙÉèÿһ¶ÎÎı¾¶¼×öΪһ¸öÃû³ÆΪFred.javaµÄÎļþµÄÈ«²¿ÄÚÈÝ£¿ a
a).
public class Fred{
public int x = 0;
public Fred (int x){
      this.x=x;
}
}
b).
public class fred{
public int x = 0;
public Fred (int x){
this.x=x;
}
}
c).
public class ......

һЩÄãÐèÒªÖªµÀµÄJava±à³Ì´úÂë¹æ·¶

Ê×ÏÈ£¬Ç¿ÁÒÍƼöÄãÏȲο¼Sun¹Ù·½µÄJava´úÂë/±à³Ì¹æ·¶£º
http://java.sun.com/docs/codeconv/html/CodeConvTOC.doc.html

Äã¿ÉÒÔ´òÆÆÒÔÉϵÄÈÎÒ»¹æÔò£¬²»¹ýÒ»¶¨ÒªÓиöºÃÀíÓÉ£¬²¢ÇҼǼÏÂÀ´¡£
ÓÀÔ¶£¬ÓÀÔ¶£¬ÓÀÔ¶²»ÒªÔÚûÓмǼ¶ÑÕ»¸ú×ÙÐÅÏ¢£¨stack trace£©»òÊÇÖØÐÂÅ׳öÒì³£µÄÇé¿öϲ¶»ñÒì³££¬Ë׳Ɠ³ÔµôÒì³£&rd ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ