this ÓësuperÔÚjavaÖÐÔËÓÃÕûºÏ
A.ʹÓùؼü×ÖthisµÄ×¼Ôò£º
1.ÔÚ¹¹ÔìÆ÷ÖУ¬Èç¹ûҪʹÓùؼü×Öthis,ÄÇô£¬±ØÐë·ÅÔÚµÚÒ»ÐУ¬·ñÔò½«µ¼ÖÂÒ»¸ö±àÒë´íÎó¡£
2.¹¹Ôì·½·¨ÒýÓÃthisÖ¸ÏòÕýÔÚÖ´Ðз½·¨µÄÀàµÄʵÀý¡£¾²Ì¬·½·¨²»ÄÜʹÓÃthis¹Ø¼ü×Ö£¬ÒòΪ¾²Ì¬·½·¨²»ÊôÓÚÀàµÄʵÀý£¬ËùÒÔthisÒ²¾ÍûÓÐʲô¶«Î÷È¥Ö¸Ïò¡£¹¹ÔìÆ÷µÄthisÖ¸Ïòͬһ¸öÀàÖУ¬²»Í¬²ÎÊýÁбíµÄÁíÍâÒ»¸ö¹¹ÔìÆ÷£¬ÎÒÃÇ¿´¿´ÏÂÃæµÄ´úÂ룺
public class Platypus {
String name;
Platypus(String input) {
name = input;
}
Platypus() {
this("John/Mary Doe");
}
public static void main(String args[]) {
Platypus p1 = new Platypus("digger");
Platypus p2 = new Platypus();
}
}
ÔÚÉÏÃæµÄ´úÂëÖУ¬ÓÐ2¸ö²»Í¬²ÎÊýÁбíµÄ¹¹ÔìÆ÷¡£µÚÒ»¸ö¹¹ÔìÆ÷£¬¸øÀàµÄ³ÉÔ±name¸³Öµ£¬µÚ¶þ¸ö¹¹ÔìÆ÷£¬µ÷ÓõÚÒ»¸ö¹¹ÔìÆ÷£¬¸ø³ÉÔ±±äÁ¿nameÒ»¸ö³õʼֵ "John/Mary Doe".
×¢Ò⣺¾¡¹Ü¿ÉÒÔÓÃthisµ÷ÓÃÒ»¸ö¹¹ÔìÆ÷£¬µ«È´²»Äܵ÷ÓÃÁ½¸ö¡£´ËÍ⣬±ØÐ뽫¹¹ÔìÆ÷µ÷ÓÃÖÃÓÚ×îÆðʼλÖ㬷ñÔò±àÒë»á³ö´í¡£
B.ʹÓÃsuperʱµÄ×¼Ôò£º
1.¹¹ÔìÆ÷ʹÓÃsuperÈ¥µ÷Óó¬ÀàÖеĹ¹ÔìÆ÷¡£¶øÇÒÕâÐдúÂë±ØÐë·ÅÔÚµÚÒ»ÐУ¬·ñÔò±àÒ뽫³ö´í¡£
2.ÎÞÂÛ¹¹ÔìÆ÷ºÍ·½·¨£¬¶¼Óùؼü×ÖsuperÖ¸Ïò³¬À࣬µ«ÊÇÓõķ½·¨²»Ò»Ñù¡£·½·¨ÓÃÕâ¸ö¹Ø¼ü×ÖÈ¥Ö´Ðб»ÖØÔصij¬ÀàÖеķ½·¨¡£
class Mammal1{
void getBirthInfo() {
System.out.println("born alive.");
}
}
class Platypus2 extends Mammal {
void getBirthInfo() {
System.out.println("hatch from eggs");
System.out.print("a mammal normally is ");
super.getBirthInfo();
}
}
public class TestMammal{
public static void main(String[] args){
Platypus2 pl = new Platypus2();
}
}
ÈýÖÖÇé¿ö˵Ã÷£º
1¡¢¸¸ÀàÖÐûÓÐÏÔʽ¶¨ÒåÈκι¹Ôì·½·¨£¬´Ëʱ¸¸ÀàÖÐʵ¼ÊÓÐÒ»¸öĬÈϵÄÎÞ²ÎÊý¹¹Ôì·½·¨¡£Õâʱ£¬ÔÚ×ÓÀàÖÐÏÔʽ¶¨ÒåÈκι¹Ô
Ïà¹ØÎĵµ£º
Javaѧϰ´ÓÈëÃŵ½¾«Í¨
Ò»¡¢ JDK (Java Development Kit)
JDKÊÇÕû¸öJavaµÄºËÐÄ£¬°üÀ¨ÁËJavaÔËÐл·¾³£¨Java Runtime Envirnment£©£¬Ò»¶ÑJava¹¤¾ßºÍJava»ù´¡µÄÀà¿â(rt.jar)¡£²»ÂÛʲôJavaÓ¦Ó÷þÎñÆ÷ʵÖʶ¼ÊÇÄÚÖÃÁËij¸ö°æ±¾µÄJDK¡£Òò´ËÕÆÎÕJDKÊÇѧºÃJavaµÄµÚÒ»²½¡£×îÖ÷Á÷µÄJ ......
1¡¢ÀàÐÍÄ£°å Class£º
ÎïÒÔÀà¾Û£º
ÎÒÃÇ¿ÉÒÔÓÃclass Person{ } class Animal{ }À´ÃèÊöÒ»ÀàÈË»òÒ»ÀදÎ
ÄÇôÔÙÏëһϣ¬ÎÒÃÇÊDz»ÊÇ¿ÉÒÔÓÃclass Class{ } À´³éÏóÃèÊöÀàÄØ£¿
´ð°¸Ê±¿ÉÒԵģ¬Õâ¾ÍÊÇjdkÖÐµÄ Class ÀࣨÀàÐ ......
1. java »ñÈ¡ipµØÖ·µÄ´úÂë
String loacalIp = "";
try
{
InetAddress localhost = InetAddress.getLocalHost();
loacalIp =localhost.getHostAddress();
  ......
¡¡JSON ¼´ Java
Script Object Natation£¬ËüÊÇÒ»ÖÖÇáÁ¿¼¶µÄÊý¾Ý½»»»
¸ñʽ£¬·Ç³£ÊʺÏÓÚ·þÎñÆ÷
Óë Java
Script µÄ½»»¥¡£±¾ÎĽ«¿ìËÙ½²½â JSON ¸ñʽ£¬²¢Í¨¹ý´úÂëʾÀýÑÝʾÈçºÎ·Ö±ðÔÚ¿Í»§¶ËºÍ·þÎñÆ÷
¶Ë½øÐÐ JSON ¸ñʽÊý¾ÝµÄ´¦Àí¡£
¡¡¡¡Json±ØÐèµÄ°ü
¡¡¡¡commons-httpclient-3.1.jar
¡¡¡¡commons-lang-2.4.jar
¡¡¡¡ ......