Ò׽ؽØÍ¼Èí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

javaÉè¼ÆÄ£Ê½£º×°ÊÎÆ÷ģʽ[Decorator]

×°ÊÎÆ÷ģʽÖ÷ÒªÓ¦ÓÃÓÚÕâÑùÒ»ÖÖ³¡ºÏ£¬µ±ÄãÒѾ­ÓÐÁËÒ»¸öÄ¿±êÀ࣬²¢ÇÒËüÊÇÒ»¸ö½Ó¿ÚµÄʵÏÖÀ࣬ÔÚ¶Ô¸ÃÀàʹÓõĺóÆÚ·¢ÏÖÐèÒª¶ÔÏàÓ¦½Ó¿Ú³ÌÐòµÄǰºó×ö¸ü¶àµÄ´¦Àí£¬ÕâЩ´¦ÀíÊDZ仯µÄ£¬²»¹Ì¶¨µÄ£¬µ«ÊÇÓв»ÄÜÈ¥ÐÞ¸ÄÕâ¸öÄ¿±êÀ࣬ÕâʱÎÒÃǾͿÉÒÔʹÓÃÕâ¸ö×°ÊÎÆ÷ģʽ£º
±ÈÈ磬ÎÒÃÇÒѾ­ÓÐÒ»¸ö¸¶¿îµÄ·½·¨ payMoney(long count) £¬Õâ¸ö·½·¨Ö»¸ºÔð½«Ç®¸¶¸ø¶Ô·½£¬²»×öÆäËû²Ù×÷£¬µ«ÊÇÕâʱÎÒÃÇÐèÒª¼Ç¼ÏÂÕâ¸ö¸¶¿îµÄ²Ù×÷£¬²¢°ÑÕâ¸ö²Ù×÷¼Ç¼µ½ÈÕÖ¾ÎļþÖÐÒÔ·½±ãÈÕºóµÄ²é¿´£¬±ÈÈçÕâ¸ö·½·¨½Ð×ö insertLog(String str) £¬ÓÐÒ»ÖÖ°ì·¨¾ÍÊÇʹÓü̳У¬²¢¸´Ð´ÏàÓ¦µÄ payMoney(long count) ·½·¨£¬ÕâÑùÒ²¿ÉÒÔÂú×ãÌõ¼þ£¬µ«ÊÇÎÊÌâ³öÀ´ÁË£¬Èç¹ûÎÒÃÇÓÖÓÐÆäËûµÄ²Ù×÷£¬ÀýÈç֪ͨ¸¶¿îÈËÒѾ­½«¿î¶î¸¶³ö notic(String username) £¬ÕâʱºòÕâô°ì£¬µ±È»ÎÒÃÇÈÔÈ»¿ÉÒÔͨ¹ý¼Ì³ÐÀ´ÊµÏÖ£¬¿ÉÊÇÈç¹ûÎÒÏÖÔÚÓв»Ï뽫¸¶¿î²Ù×÷¼Ç¼µ½ÈÕÖ¾ÎļþÖÐÁË£¬ÄÇÎÒÓÖ¸ÃÕâô°ì£¿
ΪÁ˽â¾öÕâÖÖÎÊÌ⣬ÎÒÃÇʹÓÃÁË ×°ÊÎÆ÷ģʽ £¬ÔÚÎÒÃǵÄÓ¦ÓÃÖпÉÒÔʹÓò»Í¬µÄ×°ÊÎÆ÷ÀࣨÒÔ¼°×°ÊÎÆ÷ÀàµÄ×éºÏ£©À´´ïµ½ÒÔÉϵÄÄ¿µÄ¡£
ÔÙ½«ÎÊÌâ¼ò»¯£¬ÎÒÃÇÒªÔÚ¿ØÖÆÌ¨Êä³ö×Ö·û£¬µ«ÊÇÐèÒªÔÚ×Ö·ûǰºó¼ÓÉÏ“*”ºÍ“+”£¬Ò²¾ÍÊÇ˵£¬ÎÒ¿ÉÄÜÐèÒªÔÚÎÒÊäÈëµÄ×Ö·ûǰºó¼ÓÉÏ“*”£¬Ò²¿ÉÄܹýÁË»á¶ùÓÖÏë¼Ó“+”¶ø²»ÊÇ“*”£¬»òÕßÓÖÏë“*”ºÍ“+”¶¼¼ÓÉÏ£¬ÓлòÕß¶¼²»Ïë¼Ó¡£
×°ÊÎÆ÷ģʽ ÈÃÕâЩҪÇó¶¯Ì¬µÄÅäÖóöÀ´£¬Ò²¾ÍÊÇ˵ÔÚÔËÐÐʱ²»ÐèÒª¸Ä±äÔ­À´ÒѾ­Éú³ÉºÃµÄ¶ÔÏó¡£
ÈÃÎÒÃÇÀ´¿´¿´Õâ¸ö½â¾ö·½°¸µÄ ×°ÊÎÆ÷ģʽ µÄÀàͼ°É£º
ÆäÖУ¬MyText ÀàΪÎÒÃÇÒªÏÔʾµÄ×Ö·ûÀ࣬¶ø DecoratorTextConsole ¼°Æä×ÓÀàΪÎÒÃÇµÄ ×°ÊÎÀà ¡£
¾ßÌå´úÂëÈçÏ£º
/**********************************************************************/
package decorator.interfaces;
public interface TextConsole {
public void printWords();
public void readWords();
}
/**********************************************************************/
package decorator.service;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import decorator.interfaces.TextConsole;
public class MyText implements TextConsole {
private String words;
public void printWords() {
   System.out.print(words);
}
public void readWords() {
  


Ïà¹ØÎĵµ£º

java µ÷ÓÃÃüÁî ±¸·ÝmysqlÊý¾Ý¿â

 ´úÂëÈçÏ£º
  1  String command  =   " cmd /c C:/Program Files/MySQL/MySQL Server 5.0/bin>mysqldump -h localhost -u root -p aijia > E:/aijia.dmp " ;
  2      try    {
  3     Process process& ......

java µ÷ÓÃmysql¿Í»§¶Ëµ¼È룬µ¼³öÊý¾Ý

 ×î½üÓöµ½Ò»¸öÐèÇóÒªÔÚlinuxÏÂÓÃjava µ÷ÓÃmysql¿Í»§¶ËÔ¶³ÌµÇ½mysql·þÎñÆ÷£¬´Ó¿Í»§¶Ë»úÆ÷µ¼Èëmysql½Å±¾£¬´Ómysql·þÎñÆ÷¶Ëµ¼³ö±íÖеÄÊý¾Ý¡£ÒÔÏÂÊÇÓõ½µÄÖ÷Òª·½·¨£º
Java ´úÂë 
/**  
 * µ¼ÈëÊý¾Ý  
  * @param  ½Å±¾µÄµØÖ·ºÍÃû³Æ  
 * @return ÊÇ·ñ³ ......

Java֮staticѧϰ

¶ÔÓÚѧϰstaticÎÒÃÇÏÈÀ´¿´Á½¸öÀý×Ó£º
//Example 1 Tst.java£¬no main() method
package com.blogchina.qb2049;
public class Tst
{
static { System.out.println("111111"); }
}
ÔËÐнá¹ûΪ: 111111
Exception in thread "main" java.lang.NoSuchMethodError: main
ͬÑùµÄµÀÀí¿´µÚ¶þ ......

JavaÐéÄâ»ú¼¸¸öÃüÁîÐвÎÊý˵Ã÷

Ò»¡¢ÔËÐÐclassÎļþ
Ö´Ðдømain·½·¨µÄclassÎļþ£¬ÃüÁîÐÐΪ£º
java <CLASSÎļþÃû>
×¢Ò⣺CLASSÎļþÃû²»Òª´øÎļþºó׺.class
ÀýÈ磺
java Test
Èç¹ûÖ´ÐеÄclassÎļþÊÇ´ø°üµÄ£¬¼´ÔÚÀàÎļþÖÐʹÓÃÁË£º
package <°üÃû>
ÄÇÓ¦¸ÃÔÚ°üµÄ»ù·¾¶ÏÂÖ´ÐУ¬ÃüÁîÐÐΪ£º
java <°üÃû>.CLASSÎļþ ......

JavaÖо²Ì¬±äÁ¿µÄÊÊÓó¡¾°

        JavaÀàÖеľ²Ì¬±äÁ¿ÔÚ³ÌÐòÔËÐÐÆÚ¼ä£¬ÆäÄÚ´æ¿Õ¼ä¶ÔËùÓиÃÀàµÄ¶ÔÏóʵÀý¶øÑÔÊǹ²ÏíµÄ£¬ÓÐЩʱºò¿ÉÒÔÈÏΪÊÇÈ«¾Ö±äÁ¿¡£Òò´ËÔÚijЩʱºòΪÁ˽ÚʡϵͳÄڴ濪Ïú¡¢¹²Ïí×ÊÔ´£¬¿ÉÒÔ½«ÀàÖеÄһЩ±äÁ¿ÉùÃ÷Ϊ¾²Ì¬±äÁ¿£¬Í¨¹ýÏÂÃæµÄÀý×Ó£¬Äã¿ÉÒÔ·¢ÏÖºÏÀíÓ¦Óþ²Ì¬±äÁ¿´øÀ´µÄºÃ´¦£º
¡¡¡¡Java´úÂë ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØÍ¼ | ¸ÓICP±¸09004571ºÅ