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Ïê½â
ÔÚJDK
1.4ÒÔÇ°£¬JavaµÄIO²Ù×÷¼¯ÖÐÔÚjava.ioÕâ¸ö°üÖУ¬ÊÇ»ùÓÚÁ÷µÄ×èÈû£¨blocking£©API¡£¶ÔÓÚ´ó¶àÊýÓ¦ÓÃÀ´Ëµ£¬ÕâÑùµÄAPIʹÓúܷ½
±ã£¬È»¶ø£¬Ò»Ð©¶ÔÐÔÄÜÒªÇó½Ï¸ßµÄÓ¦Óã¬ÓÈÆäÊÇ·þÎñ¶ËÓ¦Óã¬ÍùÍùÐèÒªÒ»¸ö¸üΪÓÐЧµÄ·½Ê½À´´¦ÀíIO¡£´ÓJDK 1.4Æð£¬NIO
API×÷Ϊһ¸ö»ùÓÚ»º³åÇø£¬²¢ÄÜÌṩ·Ç×èÈû(non-blo ......
JNIÊÇJava Native InterfaceµÄËõд£¬Í¨¹ýʹÓÃnative·½·¨£¬Java¿ÉÒÔµ÷Óñ¾µØC/C++×Ó³ÌÐò¡£ÉùÃ÷Ò»¸ö±¾µØ×Ó³ÌÐòµÄ·½·¨ÊÇ£ºÔÚ·½·¨ÃûÇ°Ìí¼ÓnativeÐÞÊΣ¬Èç
public native void myfun();
µ÷ÓøÃ×Ó³ÌÐòµÄ·½·¨Îª£º
static{
System.loadLibrary("myfun");
}
ÔÚWindowsÉÏ£¬ÉÏÃæµÄmyfun¼´Ö¸°üº¬ÓÃC/C++дµÄmy ......
µÚÒ»£º
1.StringÊÇ×î»ù±¾µÄÊý¾ÝÀàÐÍô£¿
´ð£º²»ÊÇ¡£»ù±¾µÄÊý¾ÝÀàÐÍ°üÀ¨£ºbyte,int,char,long,float,double,booleanºÍshort.
java.lang.StringÀàÊÇfinalÀàÐ͵ģ¬Òò´Ë²»¿ÉÒԼ̳ÐÕâ¸öÀ࣬²»ÄÜÐÞ¸ÄÕâ¸öÀà¡£
2.¾²Ì¬±äÁ¿ºÍʵÀý±äÁ¿µÄÇø±ð£¿
´ð£ºstatic i = 10 ;//³£Á¿
&nb ......
SetºÍÊýѧÖеļ¯ºÏÊÇͬһ¸ö¸ÅÄ¾ÍÊÇûÓÐÖظ´ÔªËصļ¯ºÏ¡£
ÕâƪÎÄÕÂÖ÷ÒªÂÛÊöÁËSetÊÇÈçºÎʵÏÖ"ûÓÐÖظ´ÔªËØ"£¨no duplicate elements£©µÄ£¬ÒÔ¼°²ûÊöÁËʲôÊÇ“Öظ´”£¨duplicate£©£¬ÊÇÏàͬµÄµØÖ·¿Õ¼ä£¿ÊÇequalsµÄ·µ»ØֵΪtrue£¿ÊÇcompareToµÄ·µ»ØֵΪ0 £¿»¹ÊÇÓÐÏàͬµÄhashCode£¿±¾ÎÄ»¹¸ø³öÁËÔÚʲôÇé¿öÏÂʹÓÃʲà ......
package barchartdemo1;
import java.awt.Font;
import java.io.FileOutputStream;
import java.io.IOException;
import org.jfree.chart.ChartFactory;
import org.jfree.chart.ChartUtilities;
import org.jfree.chart.JFreeChart;
import org.jfree.chart.axis.CategoryAxis;
import org.jfree.chart.axis.Numbe ......