javaÖÐÉæ¼°¹¹ÔìÆ÷µÄÏà¹ØÎÊÌâ
ÔÚ¿´µ½Thinking in java µÚËÄÕÂʱ³õʼ»¯Ïà¹ØÎÊÌâµÄʱºò£¬ÎÒÃDz»ÓɵذÑ×¢ÒâÁ¦ÒƵ½¹¹ÔìÆ÷ÉÏ¡£ÕâÀï×ö¸ö¼òµ¥µÄ×ܽᣬ±ãÓÚ¸ßÊÖÖ¸ÕýÒÔ¼°×Ô¼ºÎ¹ʡ£
Ê×Ïȹ¹ÔìÆ÷ÊÇÒª¹¹ÔìÒ»¸ö¶«Î÷{¹¹Ôì¶ÔÏó£¨ÊµÀý£©}²¢¶ÔÆä³õʼ»¯¡£Ö®ËùÒԺܶà³ÌÐòÖÐûÓп´µ½Ëü£¬ÊÇÒòΪÔÚjava³ÌÐòÖÐÈç¹ûÄãû¶¨ÒåÈκι¹ÔìÆ÷£¬Ôò±àÒëÆ÷»á×Ô¶¯¸øÄã¼ÓÉÏĬÈϹ¹ÔìÆ÷£¨²»´øÈκβÎÊý£¬Ò²Ã»ÓГ·½·¨Ì唣©¡£ÌÈÈô×Ô¼º¶¨ÒåÁ˹¹Ôì·½·¨,±àÒëÆ÷½«²»ÔÙ×Ô¶¯Ìí¼Ó¡£¹¹ÔìÆ÷ÊÇ¿ÉÒÔÌṩºÜ¶à·½·¨£¬µ«Óë¹¹Ôì·½·¨ÓÖÓÐËù²»Í¬¡£ÈçRobert Nielsen Ëù˵£¬Õâ¹Øϵ¾ÍºÃËÆ°Ä´óÀûÑǵÄѼ×ìÊÞÊÇÒ»ÖÖ²¸Óý¶¯Îï¡££¨ÒªÀí½âѼ×ìÊÞ£¬ÄÇôÏȱØÐëÀí½âËüºÍÆäËû²¸Óý¶¯ÎïµÄÇø±ð¡££©
Æä´Î¹¹ÔìÆ÷Óм¸µã¼òµ¥µÄÒªÇó£º
a£¬¹¹ÔìÆ÷Ðè²ÉÓÃÓëÀàÃûÏàͬµÄÃû³Æ£¨´óСдҲҪһÖ£©£»
b£¬¹¹ÔìÆ÷ûÓзµ»ØÖµ£¨Ò²ÎÞÐèÌí¼Óvoid£©£»
c, ¹¹ÔìÆ÷ÐÞÊηû½öÓÐpublic£¬private¼°protectedÈý¸ö£»
d£¬¹¹ÔìÆ÷Óë¹¹Ôì·½·¨´æÔÚ²»Í¬£¬Èç¹¹Ôì·½·¨²»½öÒª¸ø¶ÔÏóʵÀý±äÁ¿¸³Öµ£¬²¢ºÍnewÒ»Æð´´½¨¶ÔÏó¡£
e£¬¸¸ÀàÖеĹ¹ÔìÆ÷²»Äܱ»¼Ì³Ð£¬¸¸ÀàÖеķ½·¨¿ÉÒԼ̳С£
f£¬Í¬Ò»ÀàÖеĹ¹ÔìÆ÷¿ÉÒÔÖØÔØ¡£
g£¬×ÓÀàÓ븸À๹ÔìÆ÷±àÒëʱ³£³ö´íµÄ¹Ø¼üÈçÏ£º
ÀýÒ»£º
class A {
public A() {
System.out.println("A");
}
}
class B extends A{
public B(String str) {
System.out.println("B");
}
}
class C extends B{
public C(String str) {super(str);System.out.println("C String");
}
public C(int n) {System.out.println("C int");super("" + n);
}
}
˵Ã÷£º
±àÒë´íÎ󣬵÷Óø¸ÀàµÄ¹¹ÔìÆ÷Óï¾äÓ¦¸ÃΪÀ๹ÔìÆ÷ÖеĵÚÒ»¸öÓï¾ä¡£
ÐÞ¸ÄΪ£ºpublic C(int n) {super("" + n);System.out.println("C int");}
ʹÓãºC c = new C(10); //Êä³ö£ºA B C
Àý¶þ£º
class TestSuper{
TestSuper(int i){} &nb
Ïà¹ØÎĵµ£º
Javaѧϰ´ÓÈëÃŵ½¾«Í¨
Ò»¡¢ JDK (Java Development Kit)
JDKÊÇÕû¸öJavaµÄºËÐÄ£¬°üÀ¨ÁËJavaÔËÐл·¾³£¨Java Runtime Envirnment£©£¬Ò»¶ÑJava¹¤¾ßºÍJava»ù´¡µÄÀà¿â(rt.jar)¡£²»ÂÛʲôJavaÓ¦Ó÷þÎñÆ÷ʵÖʶ¼ÊÇÄÚÖÃÁËij¸ö°æ±¾µÄJDK¡£Òò´ËÕÆÎÕJDKÊÇѧºÃJavaµÄµÚÒ»²½¡£×îÖ÷Á÷µÄJ ......
TBCPMessageFactory.java
/**
* ÎļþÃû: TBCPMessageFactory.java
*/
package tbcpstack;
import java.text.MessageFormat;
import org.apache.log4j.Logger;
import TBCPException;
/**
*
* TODO TBCPÏûÏ¢¹¹½¨¹¤³§
*/
public class TBCPMessageFactory {
/**
* Logger for this class
......
1¡¢ÀàÐÍÄ£°å Class£º
ÎïÒÔÀà¾Û£º
ÎÒÃÇ¿ÉÒÔÓÃclass Person{ } class Animal{ }À´ÃèÊöÒ»ÀàÈË»òÒ»ÀදÎ
ÄÇôÔÙÏëһϣ¬ÎÒÃÇÊDz»ÊÇ¿ÉÒÔÓÃclass Class{ } À´³éÏóÃèÊöÀàÄØ£¿
´ð°¸Ê±¿ÉÒԵģ¬Õâ¾ÍÊÇjdkÖÐµÄ Class ÀࣨÀàÐ ......
ÔÚoracleÖе÷ÓÃjava³ÌÐò,×¢Òâ:java·½·¨±ØÐëÊÇstaticÀàÐ͵Ä,Èç¹ûÏëÔÚJAVAÖÐʹÓÃsystem.out/errÊä³ölog.
ÐèÒªÔÚoracle ÖÐÖ´ÐÐ"call dbms_java.set_output(5000);".
Ò»¡¢helloWord
1 ±àдJAVA³ÌÐò,Ò²ÊÇÔÚSQL/PLUSÖÐд,²¢Ö´ÐÐ.
create or replace and compile java source named hello as
public ......