Java½Ó¿Ú,³éÏóÀ࣬ÄÚ²¿Àà
×î½ü¿´µ½µÄһƪÎÄÕ£¬¾õµÃдµÄͦºÃ£¬¾Íת¹ýÀ´ÒÔ±ã×Ô¼ºÀ´¿´¡£
¿´µ½ÂÛ̳ÀïÓиöÌû×ÓÔÚÌÖÂ۽ӿںͳéÏóÀàµÄÇø±ðºÍ×÷Óã¬ÕâÆäʵҲÊǺܶàÃæÊÔ¹Ùϲ»¶ÎʵÄÎÊÌ⣬ÕâÀïÎÒ¾Í˵˵ÎÒµÄ×ܽᣬ˳±ã˵˵ÄÚ²¿ÀàµÄ×÷Ó㬵±ÊǸø¸ÕÈëÃÅ£¬»òÕßÏëѧϰjavaµÄͬѧÃÇÄܸüºÃµÄÀí½âËüÃǵÄÓ÷¨¡£
1.½Ó¿Ú(interface)£¬½Ó¿Ú±»ÓÃÀ´½¨Á¢ÀàÓëÀàÖ®¼ä¹ØÁªµÄ±ê×¼¡£
Java code
public interface ITest{
public void test();
}
public class TestImpl implements ITest{
public void test(){
System.out.println("test");
}
}
2.³éÏóÀà(abstract class)£¬Ö»ÒªÀàÖÐÓÐÒ»¸ö³éÏó·½·¨£¬´ËÀà¾Í±»±ê¼ÇΪ³éÏóÀࡣʵ¼ÊÉϳéÏóÀà³ýÁ˱»¼Ì³ÐÖ®ÍâûÓÐÈκÎÒâÒå¡£
Çø±ð
1.
½Ó¿ÚÊǹ«¿ª(public)µÄ£¬ÀïÃæ²»ÄÜÓÐ˽Óеķ½·¨»ò±äÁ¿,ÊÇÓÃÓÚÈñðÈËʹÓõÄ,ʵÏÖ½Ó¿ÚµÄÒ»¶¨ÒªÊµÏÖ½Ó¿ÚÀﶨÒåµÄËùÓз½·¨¡£
¶ø³éÏóÀàÊÇ¿ÉÒÔÓÐ˽Óз½·¨»ò˽ÓбäÁ¿µÄ£¬ÊµÏÖ³éÏóÀà¿ÉÒÔÓÐÑ¡ÔñµØÖØдÐèÒªÓõ½µÄ·½·¨£¬µ«ÊDZØÐëʵÏÖÀïÃæËùÓеijéÏó·½·¨¡£
2.
³éÏóÀàÔÚ Java ÓïÑÔÖбíʾµÄÊÇÒ»Öּ̳йØϵ£¬Ò»¸öÀàÖ»ÄÜʹÓÃÒ»´Î¼Ì³Ð¹Øϵ¡£
µ«ÊÇ£¬Ò»¸öÀàÈ´¿ÉÒÔʵÏÖ¶à¸öinterface(javaÖÐʵÏÖ¶àÖؼ̳еķ½·¨Ö®Ò»)¡£
3.
³éÏóÀàÖпÉÒÔÓÐ×Ô¼ºµÄÊý¾Ý³ÉÔ±£¬Ò²¿ÉÒÔÓзÇabstarctµÄ³ÉÔ±·½·¨¡£
¶øÔÚ½Ó¿ÚÖУ¬Ö»Äܹ»Óо²Ì¬µÄ²»Äܱ»Ð޸ĵÄÊý¾Ý³ÉÔ±£¨Ò²¾ÍÊDZØÐëÊÇ static finalµÄ£¬²»¹ýÔÚ interfaceÖÐÒ»°ã²»¶¨ÒåÊý¾Ý³ÉÔ±£©£¬¶øÇÒËùÓеijÉÔ±·½·¨¶¼ÊdzéÏóµÄ¡£
4.
³éÏóÀàºÍ½Ó¿ÚËù·´Ó³³öµÄÉè¼ÆÀíÄͬ¡£
Æäʵabstract class±íʾµÄÊÇ"is-a"¹Øϵ£¬interface±íʾµÄÊÇ"like-a"¹Øϵ¡££¨×éºÏÊÇ"has a"¹Øϵ£©
5.
½Ó¿ÚÖж¨ÒåµÄ±äÁ¿Ä¬ÈÏÊÇpublic static final ÐÍ£¬ÇÒ±ØÐë¸øÆä³õÖµ£¬ËùÒÔʵÏÖÀàÖв»ÄÜÖØж¨Ò壬Ҳ²»ÄܸıäÆäÖµ¡£
³éÏóÀàÖеıäÁ¿Ä¬ÈÏÊÇ friendly ÐÍ£¬ÆäÖµ¿ÉÒÔÔÚ×ÓÀàÖÐÖØж¨Ò壬Ҳ¿ÉÒÔÖØи³Öµ¡£
Ò»°ãµÄÓ¦ÓÃÀ×¼¶µÄÊǽӿڣ¬È»ºóÊdzéÏóÀàʵÏÖ½Ó¿Ú£¬×îºó²Åµ½¾ßÌåÀàʵÏÖ¡£²»ÊǺܽ¨Òé¾ßÌåÀàÖ±½ÓʵÏֽӿڵġ£»¹ÓÐÒ»ÖÖÉè¼ÆģʽÊÇÃæÏò½Ó¿Ú±à³Ì£¬¶ø·ÇÃæÏòʵÏÖ±à³Ì¡£
Æäʵ½Ó¿ÚÊdzéÏóÀàµÄÑÓÉ죬¿ÉÒÔ½«Ëü¿´×öÊÇ´¿´âµÄ³éÏóÀ࣬¾ÍÊÇ˵½Ó¿Ú±È³éÏóÀ໹³éÏ󣬻¹ÓÐÉè¼Æ½Ó¿ÚµÄÄ¿µÄ¾ÍÊÇΪÁËʵÏÖC++ÖеĶàÖؼ̳У¬²»¹ýjavaÍŶÓÉè¼ÆµÄÒ»Ñù¸üÓÐȤµÄ¶«Î÷À´ÊµÏÖÕâ¸ö¹¦ÄÜ£¬ÄǾÍÊÇÄÚ²¿Àà(inner class)¡£
ÄÚ²¿Àà(inner class)
Java code
public class OuterClass{//ÍⲿÀà
private class InnerClass{}//ÄÚ²¿Àà
}
Ò
Ïà¹ØÎĵµ£º
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.io.*;
import java.security.*;
import javax.crypto.*;
import javax.crypto.spec.*;
/**
ÎļþÃû£ºFileEncrypter.java
JDK£º1.40ÒÔÉÏ
˵Ã÷£ºÎļþ¼ÓÃÜ
¼ÓÃÜ·½·¨£ºÈýÖØDES¼ÓÃÜ
¼ÓÃܹý³Ì£º¶ÔÑ¡ÖеÄÎļþ¼ÓÃܺóÔÚͬÎļ ......
±àдһ¸ö³ÌÐò£¬ÅжÏÒ»¸ö×Ö·û´®ÊÇ·ñÊǺϷ¨µÄJava±êʶ·û£»
//create string
import java.util.regex.*;
public class Split {
public static void main (String[] args) {
Pattern pattern = Pattern.compile("[,]");
String[] arrStr = pattern.split("abstract,break,byte,boole ......
ÕâƪÎÄ×ÖдµÄºÜºÃ£¬ÍƼö¸ø×Ô¼ººÍ´ó¼Ò£¡
ÊÂÎñ²ßÂÔ: Á˽âÊÂÎñÏÝÚå
ÔÚ Java ƽ̨ÖÐʵÏÖÊÂÎñʱҪעÒâµÄ³£¼û´íÎó
¼¶±ð£º Öм¶
Mark Richards, Ö÷¹ÜºÍ¸ß¼¶¼¼Êõ¼Ü¹¹Ê¦, Collaborative Consulting, LLC
2009 Äê 3 ÔÂ 06 ÈÕ
ÊÂÎñ´¦ÀíµÄÄ¿±êÓ¦¸ÃÊÇʵÏÖÊý¾ÝµÄ¸ß¶ÈÍêÕûÐÔºÍÒ»ÖÂÐÔ¡£±¾ÎÄÊÇΪ Java ƽ̨¿ª· ......
/**
* ÓйØÈÕÆÚ¹¤¾ßÀà(extends TimeUtil)
*
* TimeUtilÖ÷Òª¹¦ÄÜÓУº
* 1.¸÷ÖÖÈÕÆÚÀàÐÍ£¨×Ö·û£¬util.Date£¬sql.Date£¬CalendarµÈ£©×ª»»
* 2.»ñÈ¡Ö¸¶¨ÈÕÆÚµÄÄê·Ý£¬Ô·ݣ¬ÈÕ·Ý£¬Ð¡Ê±£¬·Ö£¬Ã룬ºÁÃë
* 3.»ñÈ¡µ±Ç°/ϵͳÈÕÆÚ(Ö¸¶¨ÈÕÆÚ¸ñʽ)
* 4.»ñÈ¡×Ö·ûÈÕÆÚÒ»¸öÔµÄÌìÊý
* 5.»ñÈ¡Ö¸¶¨Ô·ݵĵÚÒ»Ìì,×îºóÒ»Ìì
*
* Date ......