JavaÖØÐ´ÓëÖØÔØ
ÖØÐ´µÄÖ÷ÒªÓŵãÊÇÄܹ»¶¨Òåij¸ö×ÓÀàÌØÓеÄÌØÕ÷:
Èç:
public class Father
{
public void speak()
{
System.out.println("Father");
}
}
public class Son extends Father
{
public void speak()
{
System.out.println("son");
}
}
ÕâÒ²½Ð×ö¶à̬ÐÔ,ÖØÐ´·½·¨Ö»ÄÜ´æÔÚÓÚ¾ßÓм̳йØÏµÖÐ,ÖØÐ´·½·¨Ö»ÄÜÖØÐ´¸¸Àà·Ç˽Óеķ½·¨,
µ±ÉÏÀýÖÐ FatherÀà speak()·½·¨±»privateʱ,SonÀ಻ÄÜÖØÐ´ FatherÀà speak()·½·¨,´ËʱSonÀà speak()·½·¨Ï൱ÓëÔÚSonÀàÖж¨ÒåµÄÒ»¸öspeak()·½·¨.
FatherÀà speak()·½·¨Ò»µ«±»finalʱ,ÎÞÂ۸÷½·¨±»public,protected¼°Ä¬ÈÏËùÐÞÊÎʱ,SonÀà¸ù±¾²»ÄÜÖØÐ´ FatherÀà speak()·½·¨,ÊÔͼ±àÒë´úÂëʱ,±àÒëÆ÷»á±¨´í.Àý:
public class Father
{
fianl public void speak()
{
System.out.println("Father");
&
Ïà¹ØÎĵµ£º
this
¶ÔÏó±¾Éí¡£public class ThisTest {
ThisTest tTest;
public ThisTest(){
tTest = this;
}
public void test(){
System.out.println(this);
}
public static void main(String arg[]){
new ThisTest().test();
}
}
³ÉÔ±·½·¨ÒýÓá£
³ÉÔ±±äÁ¿ÒýÓá£public class ThisTest {
String name ......
ÎÊÌâ1.
public static void append(String str){
str += " Append!";
}
public static void append(StringBuffer sBuffer){
sBuffer.append(" Append!");
}
public void test(){
String str = "Nothing";
append(str);
System.out.println(str);
StringBuffer sBuffer = new StringBuffer("Nothing" ......
ÀàÊǹ㷺µÄ¸ÅÄ±íʾһ¸öÓй²Í¬ÐÔÖʵÄȺÌå¡£È磺ÈËÀà¡£
´úÂ룺
// ÉùÃ÷Ò»¸öÀà“Human”
class Human{
priv ......
ÀàÃû£º
java.util.Date
¹¹Ôì·½·¨£º
¹¹Ôì·½·¨ ½â˵
Date()
ÎÞ²ÎÊýµÄ¹¹Ôì·½·¨£¬½«¹¹½¨Ò»¸ö±£³Öµ±Ç°ÈÕÆÚ.ʱ¼äµÄDate¶ÔÏó¡£
Date(long time)
²ÎÊýΪ1970Äê1ÔÂ1ÈÕ00ʱ00·Ö00ÃëÆðËù¾¹ýµÄºÁÃëÊý£¬½«¹¹½¨Ò»¸ö±£³Ö¸ÃÈÕÆÚ.ʱ¼äµÄ¾«È·µ½ºÁÃëµÄDate¶ÔÏó¡£
ÆäËûÓÐЩ¹¹Ôì·½·¨ÒѾ²»ÍƼöʹÓã¬ÕâÀï² ......