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λÖá
Ïà¹ØÎĵµ£º
create PROCEDURE pagelist
@tablename nvarchar(50),
@fieldname nvarchar(50)='*',
@pagesize int output,--ÿҳÏÔʾ¼Ç¼ÌõÊý
@currentpage int output,--µÚ¼¸Ò³
@orderid nvarchar(50),--Ö÷¼üÅÅÐò
@sort int,--ÅÅÐò·½Ê½£¬1±íʾÉýÐò£¬0±íʾ½µÐòÅÅÁÐ
......
1¡¢ Ò»¸öÊýÈç¹ûÇ¡ºÃµÈÓÚÆäÒò×Ó£¨³ýÁ˱¾ÉíÒÔÍâµÄÔ¼ÊýÖ®ºÍ£©£¬¸ÃÊý¾Í³ÆΪ“ÍêÊý”¡£±àдһ¸ö Java Application ³ÌÐò£¬Çó³ö 1000 ÒÔÄÚµÄËùÓÐÍêÊý¡£
public class homework11
{
public static void main(String[] args)
//Êä³ö1000ÒÔÄÚµÄËùÓÐÍêÊý
{
int sum; ......
1¡¢ ´®²Ù×÷£ºÊ¹ÓÃ×Ö·û´®´æÖüÒ»¸öÓ¢Îľä×Ó“Java is an object oriented programming
language”¡£ÏÔʾ¸Ã¾ä×Ó£¬²¢Ëã³öÿ¸öµ¥´ÊµÄ×ÖĸÊýºÍƽ¾ù×ÖĸÊý£¬²¢°´µ¥´ÊÉýÐòÅÅÁÐÊä³ö£¨²»ÓÃÊý×飬ֻÓô®²Ù×÷£©
public class homework21 {
public static void main(String[] args) {
&nb ......
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 ......
±àдһ¸ö¼òµ¥µÄÎı¾±à¼Æ÷£¬ÒªÇ󣺾ßÓдò¿ª¡¢±£´æ¡¢Ð½¨£¬Õ³Ìù¡¢¸´ÖƵȹ¦ÄÜ£»¾ßÓÐÒ»¸ö¹¤¾ßÌõ¡£±àдһ¸öÀàËÆ Windows ¼Çʱ¾µÄ¼òµ¥³ÌÐò£¬¸Ã³ÌÐòÄܹ»´´½¨ÐÂÎļþ¡¢¶ÁÈ¡ÒѾ´æÔÚµÄÎļþ¡¢²é¿´ºÍÐÞ¸ÄÎı¾ÒÔ¼°±£´æΪÎı¾Îļþ¡£
ÔÝʱ»¹²»»á×ö£¬Å¬Á¦ÖС£¡£¡£¡£¡£¡£¡£¡£ ......