JAVA ÄÚ²¿ÀàµÄ¼òµ¥×ܽá
¶¨ÒåÔÚÒ»¸öÀàÄÚ²¿µÄÀà½ÐÄÚ²¿À࣬°üº¬ÄÚ²¿ÀàµÄÀà³ÆΪÍⲿÀà¡£ÄÚ²¿Àà¿ÉÒÔÉùÃ÷public¡¢protected¡¢privateµÈ·ÃÎÊÏÞÖÆ£¬¿ÉÒÔÉùÃ÷ΪabstractµÄ¹©ÆäËûÄÚ²¿Àà»òÍⲿÀà¼Ì³ÐÓëÀ©Õ¹£¬»òÕßÉùÃ÷Ϊstatic¡¢finalµÄ£¬Ò²¿ÉÒÔʵÏÖÌض¨µÄ½Ó¿Ú¡£staticµÄÄÚ²¿ÀàÐÐΪÉÏÏóÒ»¸ö¶ÀÁ¢µÄÀ࣬·ÇstaticÔÚÐÐΪÉÏÀàËÆÀàµÄÊôÐÔ»ò·½·¨ÇÒ½ûÖ¹ÉùÃ÷staticµÄ·½·¨¡£ÄÚ²¿Àà¿ÉÒÔ·ÃÎÊÍⲿÀàµÄËùÓз½·¨ÓëÊôÐÔ£¬µ«staticµÄÄÚ²¿ÀàÖ»ÄÜ·ÃÎÊÍⲿÀàµÄ¾²Ì¬ÊôÐÔÓë·½·¨¡£
ÍⲿÀà°´³£¹æµÄÀà·ÃÎÊ·½Ê½Ê¹ÓÃÄÚ²¿À࣬ΨһµÄ²î±ðÊÇÍⲿÀà¿ÉÒÔ·ÃÎÊÄÚ²¿ÀàµÄËùÓз½·¨ÓëÊôÐÔ£¬°üÀ¨Ë½Óз½·¨ÓëÊôÐÔ¡£È磺
pinner p = new pinner();
p.index = 20;
p.Print();
---- ÕâÖÖ·½Ê½ÊʺÏÍⲿÀàµÄ·Çstatic·½·¨£»
pouter po = new pouter();
pinner pi = po.new pinner();
pi.index = 40;
pi.Print();
---- ÕâÖÖ·½Ê½ÊʺÏÍⲿÀàµÄstatic·½·¨£»
ÄÚ²¿ÀàÀàËÆÍⲿÀàµÄÊôÐÔ£¬Òò´Ë·ÃÎÊÄÚ²¿Àà¶ÔÏóʱ×ÜÊÇÐèÒªÒ»¸ö´´½¨ºÃµÄÍⲿÀà¶ÔÏó¡£ÄÚ²¿Àà¶ÔÏóͨ¹ý‘ÍⲿÀàÃû.this.xxx’µÄÐÎʽ·ÃÎÊÍⲿÀàµÄÊôÐÔÓë·½·¨¡£È磺
System.out.println("Print in inner Outer.index=" + pouter.this.index);
System.out.println("Print in inner Inner.index=" + this.index);
Èç¹ûÐèÒªÔÚÆäËûÀàÖзÃÎÊÄÚ²¿À࣬¿ÉÒÔʹÓãº
(1)ÍⲿÀàÌṩ´´½¨ÄÚ²¿ÀàµÄ·½·¨¹©ÆäËûÀàʹÓá£È磺
// ÍⲿÀà
pinner getInner()
{
return new pinner();
}
// ÆäËûÀà
pouter.pinner pi = po.getInner();
&nb
Ïà¹ØÎĵµ£º
package com.yzy;
import java.util.regex.*;
public class Test {
/**
* @param args
*/
public static void main(String[] args) {
Pattern p=Pattern.compile("^[a-z]+");
Matcher m=p.matcher("a233"); //true
//Matcher m=p.matcher("2233") ......
Java ÖÐÄÚ²¿¶¯Ì¬Àà(ûÓÐstatic)¹Ø¼ü×ÖºÍÄÚ²¿¾²Ì¬ÀàµÄ¾ÍÔÚÓÚÄÚ²¿¶¯Ì¬À಻Äܶ¨Ò徲̬±äÁ¿»òÊǾ²Ì¬·½·¨,Èç¹ûÒªÔÚÄÚ²¿ÀàÖÐʹÓþ²Ì¬³ÉÔ±,±ØÐ뽫ÀàÉùÃ÷Ϊ¾²Ì¬Àà.
ÄÚ²¿ÀàÖеľ²Ì¬·½·¨¿ÉÒÔ·ÃÎÊÍⲿÀàµÄ¾²Ì¬·½·¨ºÍ±¾ÀàÖеľ²Ì¬·½·¨»ò³ÉÔ±, ·Ç¾²Ì¬·½·¨¿ÉÒÔ·ÃÎÊÆäËûËùÓеķ½·¨»ò³ÉÔ± ......
ÓÐʱ£¬ÎÒÃÇÔÚдһ¸ö¹¹Ô캯Êýʱ£¬¾³£ÒòΪËü°üº¬ÖÚ¶àµÄ²ÎÊý¶ø¿àÄÕ,Õâʱ¿ÉÒÔ¿¼ÂÇÓÃBuilderģʽÀ´´´½¨¶ÔÏó¡£
È磬ÎÒÃÇÒªÉè¼ÆÒ»¸öÓªÑø³É·ÝµÄÀ࣬°üº¬ÄÜÁ¿£¬µ°°×ÖÊ£¬Ö¬·¾£¬¸Æ£¬Ìú£¬Ð¿£¬Î¬ÉúËØA, άÉúËØB1 ... µÈ£¬µ«ÔÚ¹¹ÔìµÄʱºò£¬²»Ò»¶¨Ã¿´Î¶¼ÐèÒªÕâЩ²ÎÊý£¬Èç¸Æ£¬Ìú£¬Ð¿ºÍάÉúËصÈÊÇ¿ÉÑ¡µÄ£¬ÎªÁËÊÊÓ¦¶àÖÖ¿ÉÄܵĴîÅ䣬±È½ÏÔʼ ......
Õâ¸öÔÔòºÜ¼òµ¥£¬¾ÍÊÇʹÓÃ˽Óй¹Ô캯Êý·ÀÖ¹À౻ʵÀý»¯¡£
ÓÐʱ£¬ÎÒÃÇ»áдһЩ¹¤¾ßÀ࣬Èçjava.lang.Math »òÊÇ java.util.Arrays, ÕâЩÀàÖж¼ÊǾ²Ì¬º¯Êý£¬ÔÚÉè¼ÆµÄʱºò£¬ÕâЩÀಢ²»ÊÇÓÃÀ´±»ÊµÀý»¯µÄ¡£Õâ¸öʱºò£¬¾ÍºÜÓбØÒª°Ñ¹¹Ô캯Êý˽Óл¯¡£
public class UtilityClass {
private UtilityClass() {
throw new Assertion ......
Finalizer ²»¿É¼Æ»®µÄ,Ò²ÊÇΣÏÕµÄ,Ò»°ãÒ²ÊDz»±ØÒªµÄ.
²»ÄÜÔÚfinalizerÖзÅÈκÎÓëÒÀÀµÊ±¼äÏà¹ØµÄ²Ù×÷,ÒòΪÄã²»ÖªµÀËüʲôʱºò±»Ö´ÐÐ. ±ÈÈçÔÚfinalizerÖйرÕÎļþµÄ×ö·¨¾ÍÊÇ´íÎóµÄ, ¸ù¾ÝJVMµÄʵÏÖ·½Ê½²»Í¬,ÓпÉÄܵ¼Ö´ò¿ªµÄÎļþÊý¹ý¶à¶øÎÞ·¨ÔÙ´ò¿ªÎļþ.
Ò²²»ÄÜÔÚfinalizerÖиıä״̬,Èç¸øÊý¾Ý¿â½âËøµÈ.
finalizer»¹ÄÜ´øÀ´Ñ ......