JAVA¼¯ºÏÀà
java.util°üÖоͰüº¬ÁËһϵÁÐÖØÒªµÄ¼¯ºÏÀ࣬¶ø¶ÔÓÚ¼¯ºÏÀ࣬Ö÷ÒªÐèÒªÕÆÎյľÍÊÇËüµÄÄÚ²¿½á¹¹£¬ÒÔ¼°±éÀú¼¯ºÏµÄµü´úģʽ¡£
½Ó¿Ú£ºCollection
ËùÓм¯ºÏÀàµÄ¸ùÀàÐÍ£¬Ö÷ÒªµÄÒ»¸ö½Ó¿Ú·½·¨£ºboolean add(Ojbect c)Ëä·µ»ØµÄÊÇboolean£¬µ«²»ÊDZíʾÌí¼Ó³É¹¦Óë·ñ£¬ÒòΪCollection¹æ¶¨£ºÒ»¸ö¼¯ºÏ¾Ü¾øÌí¼ÓÕâ¸öÔªËØ£¬ÎÞÂÛʲôÔÒò£¬¶¼±ØÐëÅ׳öÒì³££¬Õâ¸ö·µ»ØÖµ±íʾµÄÒâÒåÊÇadd()Ö´Ðк󣬼¯ºÏµÄÄÚÈÝÊÇ·ñ¸ÄÁË£¨¾ÍÊÇÔªËØÓÐÎÞÊýÁ¿¡¢Î»Öõȱ仯£©¡£ÀàËƵÄaddAll£¬remove£¬removeAll£¬remainAllÒ²ÊÇÒ»ÑùµÄ¡£
ÓÃIteratorģʽʵÏÖ±éÀú¼¯ºÏ
CollectionÓÐÒ»¸öÖØÒªµÄ·½·¨£ºiterator()£¬·µ»ØÒ»¸öIterator£¨µü´ú×Ó£©£¬ÓÃÓÚ±éÀú¼¯ºÏµÄËùÓÐÔªËØ¡£Iteratorģʽ¿ÉÒÔ°Ñ·ÃÎÊÂß¼´Ó²»Í¬ÀàµÄ¼¯ºÏÀàÖгéÏó³öÀ´£¬´Ó¶ø±ÜÃâÏò¿Í»§¶Ë±©Â¶¼¯ºÏµÄÄÚ²¿½á¹¹¡£
for(Iterator it = c.iterator(); it.hasNext();) {...}
²»ÐèҪά»¤±éÀú¼¯ºÏµÄ“Ö¸Õ딣¬ËùÓеÄÄÚ²¿×´Ì¬¶¼ÓÐIteratorÀ´Î¬»¤£¬¶øÕâ¸öIteratorÓɼ¯ºÏÀàͨ¹ý¹¤³§·½·¨Éú³É¡£
ÿһÖÖ¼¯ºÏÀà·µ»ØµÄIterator¾ßÌåÀàÐÍ¿ÉÄܲ»Í¬£¬µ«ËüÃǶ¼ÊµÏÖÁËIterator½Ó¿Ú£¬Òò´Ë£¬ÎÒÃDz»ÐèÒª¹ØÐĵ½µ×ÊÇÄÄÖÖIterator£¬ËüÖ»ÐèÒª»ñµÃÕâ¸öIterator½Ó¿Ú¼´¿É£¬Õâ¾ÍÊǽӿڵĺô¦£¬ÃæÏò¶ÔÏóµÄÍþÁ¦¡£
Ҫȷ±£±éÀú¹ý³Ì˳ÀûÍê³É£¬±ØÐë±£Ö¤±éÀú¹ý³ÌÖв»¸ü¸Ä¼¯ºÏµÄÄÚÈÝ£¨IteratorµÄremove()·½·¨³ýÍ⣩£¬ËùÒÔ£¬È·±£±éÀú¿É¿¿µÄÔÔòÊÇ£ºÖ»ÔÚÒ»¸öÏß³ÌÖÐʹÓÃÕâ¸ö¼¯ºÏ£¬»òÕßÔÚ¶àÏß³ÌÖжԱéÀú´úÂë½øÐÐͬ²½¡£
JAVA Map¼¯ºÏÀà½éÉÜ
Ö±½ÓÌùÁ´½ÓºÃÁË
http://dev.csdn.net/article/54/54534.shtm
ÏßÐÔ±í£¬Á´±í£¬¹þÏ£±íÊdz£ÓõÄÊý¾Ý½á¹¹£¬ÔÚ½øÐÐJava¿ª·¢Ê±£¬JDKÒѾΪÎÒÃÇÌṩÁËһϵÁÐÏàÓ¦µÄÀàÀ´ÊµÏÖ»ù±¾µÄÊý¾Ý½á¹¹¡£ÕâЩÀà¾ùÔÚjava.util°üÖС£±¾ÎÄÊÔͼͨ¹ý¼òµ¥µÄÃèÊö£¬Ïò¶ÁÕß²ûÊö¸÷¸öÀàµÄ×÷ÓÃÒÔ¼°ÈçºÎÕýȷʹÓÃÕâЩÀà¡£
Collection
©ÀList
©¦©ÀLinkedList
©¦©ÀArrayList
©¦©¸Vector
©¦¡¡©¸Stack
©¸Set
©¦
©¸Map
©ÀHashtable
©ÀHashMap
©¸WeakHashMap
Collection½Ó¿Ú
¡¡¡¡CollectionÊÇ×î»ù±¾µÄ¼¯ºÏ½Ó¿Ú£¬Ò»¸öCollection´ú±íÒ»×éObject£¬¼´CollectionµÄÔªËØ£¨Elements£©¡£Ò»Ð©CollectionÔÊÐíÏàͬµÄÔªËضøÁíһЩ²»ÐС£Ò»Ð©ÄÜÅÅÐò¶øÁíһЩ²»ÐС£Java SDK²»Ìṩֱ½Ó¼Ì³Ð×ÔCollectionµÄÀ࣬Java SDKÌṩµÄÀ඼ÊǼ̳Ð×ÔCollectionµÄ“×Ó½Ó¿Ú”ÈçListºÍSet¡£
¡¡¡¡ËùÓÐʵÏÖCollection½Ó¿ÚµÄÀà¶
Ïà¹ØÎĵµ£º
RMI (Remote Method Invocation£¬Ô¶³Ì·½·¨µ÷ÓÃ)ÈçºÎÓÃÓÚ³ÌÐò¼äͨѶ£¬ÁíÒ»¸öÓÃÓÚͨѶµÄ¼¼ÊõÊÇRuntime.exec() ·½·¨¡£Äã¿ÉÒÔÓÃÕâ¸ö·½·¨´ÓÒ»¸öÔËÐа¢java³ÌÐòÖе÷ÓÃÁíÒ»¸ö³ÌÐò¡£Runtime.exec Ò²ÔÊÐíÄãÖ´ÐкͳÌÐòÏà¹ØµÄ²Ù×÷£¬ÀýÈç¿ØÖƳÌÐòµÄ±ê×¼ÊäÈëÊä³ö£¬µÈ´ý³ÌÐòµÄ½áÊø²¢µÃµ½ËüµÄÍ˳ö״̬¡£ÏÂÃæÊÇÒ»¸ ......
import java.awt.*;
import java.awt.event.*;
public class TestFrame {
Frame fm = new Frame();
public void init(){
fm.setSize(300,300);
Button btn = new Button("ok");
fm.add(btn);
btn.addActionListener(ne ......
ѸÀ×ÃæÊÔ»ØÀ´£¬ÓÃÁËÕûÕûÒ»ÏÂÎ磨²»ÖªµÀÔõô˵ÁË£¬ÆäÖеȴýʱ¼ä¶¼¿ì2СʱÁË£©£¬×Ô¼º¸Ð¾õ±ÊÊÔºÍÉÏ»ú»¹¿ÉÒÔ£¬µ«¼¼ÊõÃæ̸ÕâÒ»¹Ø´ðµÃ²»Ì«ºÃ£¬ÏÖÔÚÔٴθоõ»¥ÁªÍø¹«Ë¾ÓëÒ»°ãÈí¼þ¹«Ë¾µÄÇø±ðÁË£¬ÆäÖÐÒ»µã¾ÍÊÇ»¥ÁªÍøÓ¦ÓÃÔÚÐÔÄÜÉÏÒªÇóºÜ¸ß£¬Ì¸ÁËÒ»¸öСʱ´ó²¿·ÖÌâÄ¿¸Ð¾õ¶¼ÔÚ̸ÂÛÐÔÄÜÎÊÌ⣬×Ô¼ºÔÚ·½ÃæÒ»Ö±ÊÇÈõÏº¹°¡£º£¨
×Ðϸ»ØÒäÁË ......
ÏÈ¿´¿´ÏÂÃæµÄ´úÂ룬´ó¼Ò²Â²ÂÊä³öÊÇʲô
package com.captain.test;
public class ArrayTest {
public static void main(String[] args){
//н¨Ò»¸ö¶ÔÏó£¨OneNum£©Êý×飨¸³ÖµÎª5¡¢3¡¢4£©
OneNum[] ac = {new OneNum(5),new OneNum(3),new OneNum(4)};
//н¨Ò»¸öÓëacͬ³¤¶ÈµÄ¶ÔÏó£¨OneNum£©Êý×é
OneNum[] n ......
³õ̽javaÄÚ´æ»úÖÆ_¶ÑºÍÕ»
ÎÊÌâµÄÒýÈ룺
ÎÊÌâÒ»£º
String str1 = "abc";
String str2 = "abc";
System.out.println(str1==str2); //true
ÎÊÌâ¶þ£º
String str1 =new String ("abc");
String str2 =new String ("abc");
System.out.println(str1==str2); // false
ÎÊÌâÈý£º
String s1 = "ja";
String s2 = "v ......