java¼òµ¥¾²Ì¬´úÀí£¨¾ÛºÏ£©
¶¨ÒåÒ»¸ö½Ó¿Ú
package com.beckham;
/*
* ¶¨ÒåÒ»¸ö½Ó¿Ú
*/
public interface Move {
public void move() ;
}
ºËÐĵÄʵÏÖÀà
package com.beckham;
/*
* ×î³õµÄ½Ó¿ÚʵÏÖ
*/
public class Tank implements Move {
public void move() {
System.out.println("̹¿Ë¿ª¶¯.......");
}
}
ʵÏÖ·½·¨Ê±¼Ç¼ʱ¼ä
package com.beckham;
public class TankTime implements Move {
// ʵÏÖ×îÔʼµÄ½Ó¿Ú
private Move move;
public TankTime(Move move) {
this.move = move;
}
public void move() {
System.out.println(System.currentTimeMillis());
move.move();
}
}
ʵÏÖ·½·¨Ç°ºó¼ÓÈëÈÕÖ¾
package com.beckham;
public class TankLog implements Move {
// ʵÏÖ×îÔʼµÄ½Ó¿Ú
private Move move;
public TankLog(Move move) {
this.move = move;
}
public void move() {
System.out.println("̹¿Ë¿ªÊ¼ÈÕÖ¾......");
move.move();
System.out.println("̹¿Ë½áÊøÈÕÖ¾......");
}
}
¾ÛºÏʵÏÖ
package com.beckham;
public class Test {
public static void main(String[] args) {
// ×î³õµÄʵÏÖÀà
Move m = new Tank();
// ×îÀïÃæµÄ´úÀí
TankLog tl = new TankLog(m);
// ÍâÃæµÄ´úÀí
TankTime tt = new TankTime(tl);
//½Ó¿ÚµÄ¾ÛºÏ
tt.move();
}
}
²âÊÔ½á¹û
1262316711937
̹¿Ë¿ªÊ¼ÈÕÖ¾......
̹¿Ë¿ª¶¯.......
̹¿Ë½áÊøÈÕÖ¾......
µ½´ËΪֹ£¬Ò»¸ö¼òµ¥µÄ¾²Ì¬´úÀí¾ÍÍê³ÉÁË£¬ÆäʵÍê³ÉµÄ¹¦ÄܾÍÊÇÒªÔÚÒѾʵÏֵĽӿڵķ½·¨Ç°ºó¼ÓһЩÓëºËÐÄÎ޹صŦÄÜ£¬²ÉÓýӿڵľۺÏʵÏֱȽÏÁé»î¡£
Ïà¹ØÎĵµ£º
ÀàµÄ³õʼ»¯ºÍ¶ÔÏó³õʼ»¯ÊÇ JVM ¹ÜÀíµÄÀàÐÍÉúÃüÖÜÆÚÖзdz£ÖØÒªµÄÁ½¸ö»·½Ú£¬Google ÁËÒ»±éÍøÂ磬ÓйØÀà×°ÔØ»úÖƵÄÎÄÕµ¹ÊDz»ÉÙ£¬È»¶øÀà³õʼ»¯ºÍ¶ÔÏó³õʼ»¯µÄÎÄÕ²¢²»¶à£¬ÌرðÊÇ´Ó×Ö½ÚÂëºÍ JVM ²ã´ÎÀ´·ÖÎöµÄÎÄÕ¸üÊÇÏÊÓÐËù¼û¡£
±¾ÎÄÖ÷Òª¶ÔÀàºÍ¶ÔÏó³õʼ»¯È«¹ý³Ì½øÐзÖÎö£¬Í¨¹ýÒ»¸öʵ¼ÊÎÊÌâÒýÈ룬½«Ô´´úÂëת»»³É JVM ×Ö½ÚÂëºó£¬ ......
¸÷ÖÖ²»Í¬µÄJava °æ±¾£¬ÔÚÆäÖ§Ô®µÄºËÐÄÀà±ðº¯Ê½¿âÖ®ÍêÕûÐÔÒÔ¼°ËùÖ§Ô®µÄ Java »ù±¾ÐͱðÕâÁ½¼þÊÂÇéÉ϶¼ÓÐËù²îÒ죬Ҳ¾ÍÊÇ˵£¬²»¹ÜÄú¿ª·¢µÄÊÇÆóÒµËùʹÓõÄJava ³ÌÐò¡¢Ç¶ÈëʽװÖÃÉÏÖ´ÐеÄJava ³ÌÐò¡¢ä¯ÀÀÆ÷ÉÏÖ´ÐеÄApplet £¬»òÊÇÔÚPC ÉÏÖ´ÐеÄÓ¦ÓóÌÐò¡£Äú¶¼±ØÐëÔÚÄúµÄµçÄÔÉÏÏÈ°²×° J2SE £¬È»ááÔÙ°²×°¸÷ÖÖ°æ±¾µÄºËÐÄÀà± ......
/*
* @ Lunar.java
* @ ¸ù¾Ý¹«ÀúÈÕÆÚy/m/dÍÆËã³öÅ©ÀúÈÕÆÚ(ÊôÏó£¬ÌìÖ§µØ¸ÉµÈ)
* @ author Qiangwei He
* @ v1.0 2009/12/10 jdk1.6 compile
*
* field:
* int y,m,d; &n ......
Java¼ÓÃÜÓë½âÃÜ£¨by quqi99£©
×÷ÕߣºÕÅ»ª ·¢±íÓÚ£º2009-12-31
°æ鬃 ......