java¼¯ºÏ
javaÖеÄËÄÖÖÀàÐ͵ļ¯ºÏÀà
£¨1£©Vector £¨2£©BitSet£¨3£©Stack£¨4£©HashTable
2ö¾ÙÆ÷
ÔÚÈκμ¯ºÏÀàÖУ¬±ØÐëͨ¹ýijÖÖ·½·¨ÔÚÆäÖÐÖÃÈë¶ÔÏó£¬ÔÙÓÃÁíÒ»ÖÖ·½·¨´ÓÖÐÈ¡µÃ¶ÔÏó¡£ÔÚVectorÖУ¬addElement()¾ÍÊÇÎÒÃDzåÈë¶ÔÏó²ÉÓõķ½·¨
£¬¶þelementAt()ÔòÊÇÌáÈ¡¶ÔÏóµÄΨһ·½·¨¡£
Iterator¿ÉÒÔ´ïµ½Õâ¸öÄ¿µÄ£¬ËüÊÇÒ»¸ö¶ÔÏó£¬×÷ÓÃÊDZãÀûһϵÁеĶÔÏ󣬲¢Ñ¡ÔñÄǸöÐòÁÐÖеÄÿ¸ö¶ÔÏó£¬Í¬Ê±²»Èÿͻ§³ÌÐòÔ±ÖªµÀ»ò¹Ø×¢ÄǸöÐòÁеÄ
»ù´¡½á¹¹¡£
javaÄÚ²¿“×Ô¶¯×ª»»³É×Ö´®¼¼Êõ”¡£Ò»µ©±àÒëÆ÷Åöµ½Ò»¸ö×Ö´®£¬ºóÃæ¸ú×ÅÒ»¸ö+£¬¾Í»áÏ£ÍûºóÃæ¸úËæ×ÅÒ»¸ö×Ö´®£¬²¢ÇÒ×Ô¶¯µ÷ÓÃtoString()·½·¨£¬ËùÒÔtoString£¨£©·½·¨Ó¦¸ÃÖØÔØ¡£
Èô²»×¢ÒâÉÏÃæµÄʵÀý¾Í»á³öÏÖbug£¬
ÀýÈçÏÂÃæµÄʵÀý
import java.util.* ;
public class Crash{
public String toString(){
return "Crash java" + this ;//´Ë´¦this»áµ÷ÓÃtoString()·½·¨£¬ÒýÆðµÝ¹é
}
public static void main(String [] args){
Vector v = new Vector();
for(int i = 0 ; i < 10 ; i++)
v.addElement(new Crash());
System.out.println(v);
}
}
ÔÚjava6.0ÖУ¬±àÒëÆ÷»á¼ì²é³ö¸Ä´íÎó¡£
3BitSet
BitSetʵ¼ÊÊÇÓÉ“¶þ½øÖÆλ”¹¹³ÉµÄÒ»¸öVector£¬×îС³¤¶ÈÊÇ64λµÄ¡£
4Stack
5HashTable
ͨ³£Çé¿öÏÂÉ¢ÁÐÂëÊÇÿ¸ö¶ÔÏóµÄhashCode()·½·¨£¬¶ø¸Ã·½·¨·µ»ØµÄÊÇÿ¸ö¶ÔÏóµÄµØÖ·£¬Èç¹ûÒª½«×Ô¼ºÐ½¨µÄÀà×÷Ϊ¼üÖµ£¬¾ÍÓ¦¸Ã¸²¸ÇhashCode()·½·¨ºÍequals()·½·¨¡£¾ÍÏòÏÂÃæչʾµÄÄÇÑù ¡£
import java.util.*;
class Prediction{
boolean shadow = Math.random() > 0.5 ;
public String toString(){
if(shadow)
return "Six more weeks of Winter" ;
else
return "Early Spring";
}
}
class Groundhog2{
int ghNumber ;
Groundhog2(int n){
ghNumber = n;
}
public int hashCode(){
return ghNumber ;
}
&nb
Ïà¹ØÎĵµ£º
ÎÊÌâ
ÔÚǰһС½Ú£¬½éÉÜÁËÔÚ¶àÏ̱߳à³ÌÖÐʹÓÃͬ²½»úÖƵÄÖØÒªÐÔ£¬²¢Ñ§»áÁËÈçºÎʵÏÖͬ²½µÄ·½·¨À´ÕýÈ·µØ·ÃÎʹ²Ïí×ÊÔ´¡£ÕâЩÏß³ÌÖ®¼äµÄ¹ØϵÊÇƽµÈµÄ£¬±Ë´ËÖ®¼ä²¢²»´æÔÚÈκÎÒÀÀµ£¬ËüÃǸ÷×Ô¾ºÕùCPU×ÊÔ´£¬»¥²»ÏàÈ㬲¢ÇÒ»¹ÎÞÌõ¼þµØ×èÖ¹ÆäËûÏ̶߳Թ²Ïí×ÊÔ´µÄÒì²½·ÃÎÊ¡£È»¶ø£¬Ò²ÓкܶàÏÖʵÎÊÌâÒªÇó²»½öҪͬ²½µÄ·ÃÎÊͬһ¹²Ïí×ÊÔ´£¬¶øÇ ......
¹¤×÷̨´°¿ÚµÄEditorÇøÓòĬÈÏÊÇÏÔʾµÄ£¬¶øÇÒËüÖ§³ÖÍÏק²Ù×÷¡£ÔÚEclipseÀïÃ棬°ÑÒ»¸öÎļþÍϵ½EditorÇøÓò£¬¾Í»á×Ô¶¯´ò¿ª¸ÃÎļþµÄ
Editor.¸ÃÌØÐÔÊÇÔÚIWorkbenchWindowConfigurer ÖÐÉèÖá£
ÔÚPassWord GateÖУ¬µ±Í϶¯Password Gate ViewÖеÄÒ»¸öGroup »òÕß
Serviceµ½EditorÇøÓò£¬»áÔÚEditorÏÔʾ¸Ã ......
JAVA³ÌÐòµÄÍâ±í×ÜÊÇÒ»°åÒ»Ñ۵ģ¬¿´¶àÁËÄÑÃâÉóÃÀÆ£ÀÍ£¬Äܲ»ÄÜʹÎÒÃǵÄJAVA³ÌÐòÍâ¹Û±äµÃ¸üÃÀ¹Û¸ü¶ÀÌØÄØ£¿´ð°¸Êǿ϶¨µÄ£¬ÎÒÃÇ¿ÉÒÔÈÃJAVA³ÌÐò¸ù¾ÝͼƬÀ´Éú³É×Ô¶¨ÒåµÄ²»¹æÔò´°Ìå¡£±ÈÈçÏÂͼµÄÕâÖÖÍâ¹Û£º
ͼÖеÄÕâ¸öÈËÎï(ÀÙÃ×ÀòÑÇ)±ãÊǶ¨ÒåºÃµÄ²»¹æÔò´°Ì壬ÔõôÑù£¿ºÜƯÁÁ°É£¡ÄÇôÈÃÎÒÃÇ¿ªÊ¼Ñ§Ï°°É¡£
Ê×ÏÈÒªË ......
ÔÚʵÏÖsingletonģʽʱ£¬ÎÒÃÇÓÐÒÔϼ¸ÖÖ·½·¨¡£
1. public static final ×ֶμÓÉÏprivate µÄ¹¹Ô캯Êý¡£
public class Singleton{
public static final Singleton INSTANCE = new Singleton();
& ......
Õâ¸öÔÔòºÜ¼òµ¥£¬¾ÍÊÇʹÓÃ˽Óй¹Ô캯Êý·ÀÖ¹À౻ʵÀý»¯¡£
ÓÐʱ£¬ÎÒÃÇ»áдһЩ¹¤¾ßÀ࣬Èçjava.lang.Math »òÊÇ java.util.Arrays, ÕâЩÀàÖж¼ÊǾ²Ì¬º¯Êý£¬ÔÚÉè¼ÆµÄʱºò£¬ÕâЩÀಢ²»ÊÇÓÃÀ´±»ÊµÀý»¯µÄ¡£Õâ¸öʱºò£¬¾ÍºÜÓбØÒª°Ñ¹¹Ô캯Êý˽Óл¯¡£
public class UtilityClass {
private UtilityClass() {
throw new Assertion ......