Chapter 05 _Objects and Classes(core JavaÕªÒª)
Basic concepts in OOP
Encapsulation:Òþ²ØʵÏÖ¹ý³Ì£¬¶ÔÍâÌṩ¹«¿ªÒ»ÖµĽӿڡ¢Ê¹Èí¼þÒ×ÓÚ¸üÐÂÓëά»¤¡£
Polymorphism£ºÒ»¸öÊÂÎï×Ô¶¯»ñµÃÁíÒ»ÊÂÎïµÄ״̬ÐÐΪµÄ»úÖÆ¡£
Inheritance£ºÒ»¸öÀà×Ô¶¯»ñµÃÁíÒ»¸öÀàµÄÊôÐÔ»òÕß·½·¨µÄ¹ý³Ì¡£
1.ÀàµÄ½á¹¹
ˈ̞
ÊôÐÔÃû
¾²Ì¬ÊôÐÔ
ʵÀýÊôÐÔ£º±ØÐëÒÀÀµÓÚ¶ÔÏó/ʵÀý
·½·¨
¾²Ì¬·½·¨
ʵÀý·½·¨
¹¹ÔìÆ÷
ȱʡ¹¹ÔìÆ÷
´ø²ÎµÄ¹¹ÔìÆ÷
¾²Ì¬´úÂë¿é
ʵÀý´úÂë¿é
2.²ÎÊý´«µÝ
¶ÔÓÚ»ù±¾ÀàÐÍ£¬½«Êµ¼Ê²ÎÊýµÄÖµÔÑùµÄ¸´ÖÆÒ»±é´«Öµ;
¶ÔÓÚÒýÓÃÀàÐÍ£¬½«ÒýÓÃÀàÐͱäÁ¿µÄµØÖ·Öµ¸´ÖƸøʵ²Î¡£
3.Where can we use “this”£¿
A.ʵÀý±äÁ¿ÓÚ¾Ö²¿±äÁ¿Í¬Ãû£¬ÓÃthis¡£ÊµÀý±äÁ¿ÃûÀ´ºÍ¾Ö²¿±äÁ¿¼ÓÒÔÇø·Ö;
B.ÔÚ¹¹ÔìÆ÷µÄÖØÔصÄʱºò£¬ÓÃthisÀ´µ÷ÓÃÆäËûµÄ¹¹ÔìÆ÷;
C.ÔÚʵÀý·½·¨ÖУ¬ÓÃÀ´½«µ±Ç°¶ÔÏóµÄÒýÓô«µÝ¸øÁíÍâµÄ·½·¨¡£
4.·½·¨µÄÖØÔØ
A.·½·¨ÃûÒªÏàͬ;
B.ÔÚÒ»¸öÀàÖУ¬¶à¸ö·½·¨¾ßÓв»Í¬µÄ·½·¨Ç©Ãû(²ÎÊýÀàÐÍ/²ÎÊý¸öÊý/²ÎÊý˳Ðò)£¬·½·¨¿ÉÒÔÖØÔØ
C.·µ»ØÀàÐͲ»×÷ÒªÇó
5.ÀàµÄ³õʼ»¯µÄ¹ý³Ì£º
ÀàµÄ¾²Ì¬³ÉÔ±ÔÚÀà±»¼ÓÔصÄʱºò½øÐгõʼ»¯!
(1) ÔÚ¶ÑÖзÖÅä¿Õ¼ä;
(2) ¸ø¶ÔÏóµÄÊôÐÔ¸³Ä¬ÈÏÖµ
boolean=false;
»ù±¾ÀàÐÍ=0;
ÒýÓÃÀàÐÍ=null;
&nbs
Ïà¹ØÎĵµ£º
Ôڳɹ¦ÊµÏÖJavaµ÷ÓÃC++Ö®ºó£¬½ÓÏÂÀ´Ïëµ½ÄÜ·ñͨ¹ýJNAʵÏÖJavaµ÷ÓÃFortran£¬½ñÌìÊÔÑéÁËһϣ¬»¹ÊDZȽÏÈÝÒ׵ġ£
ÍøÉÏÓÐÒ»¸öJavaµ÷ÓÃF95µÄÀý×Ó£¬µ«ÊÇÎÒ¿¼ÂDz»½öҪʵÏÖF95µÄµ÷Ó㬻¹ÒªÊµÏÖF77µÄµ÷Óã¬ËùÒÔ·ÑÁËһЩÖÜÕÛ¡£
ÎÊÌâµÄ¹Ø¼üÔÚÓÚF77Ϊ¹ý³ÌÃû×Ô¶¯Ìí¼ÓÁËÒ»¸öβ²¿µÄÏ»®Ïߣ¬ËùÒÔsub1Õâ¸ö¹ý³Ì£¬µ½JavaÒ»¶Ë£¬¾Í±ä³ÉÁËsub1_£¬ ......
1.1.1 ÐÞÁ¶µÚÒ»²ã¾³½ç£º½£Ö¸ËÄ·½£¬ÊÔÎÊÌìÏÂÓëÕù·æ
ÐÞÁ¶µÚÒ»²ã¾³½çµÄ³ÌÐòÔ±£¬¶ÔJava¿ª·¢¼¼Êõ¾¡ÊýÕÆÎÕ£¬¿ª·¢¹¤¾ßÕÆÎÕµÃÒ²½ÏΪæµÊì¡£¿ÉÒÔ½«µÚ¶þ²ã´Î³ÌÐòÔ±½»¸øµÄÈÎÎñÍê³ÉµÃºÜ³öÉ«£¬¿ÉÒÔ°´ÒªÇó¶ÀÁ¢Íê³ÉÀà¡¢½Ó¿ÚºÍËã·¨µÄ¿ª·¢¡£×¢Öؼ¼ÇÉ£¬¶Ô¾ßÌåµÄ±à³ÌÓïÑԷdz£ÊìϤ¡£
ÄÜÁ¦Ö®Ëù¼°£¬½ÔÎÞ²»ÓÃÆ伫¡£ÈÏΪËùÓпª·¢ÖªÊ¶£¬Ô½ÊÇ¿´Æ ......
ÒýÓÃÓÚ£ºhttp://blog.csdn.net/hhzxj2008/archive/2010/01/10/5171444.aspx
public static boolean validatePersonalId(String personalId) {
if ((personalId == null) || ((personalId.length() != 15) &&
(personalId.length() != 18))) {
return ......
½Ó¿ÚºÍ³éÏóÀàÊÇjavaÖÐ×îÖØÒªµÄ2¸öÌØÕ÷£¬ÔÚ±¾ÊéÖÐдµ½Á˾ßÌåµÄÓ¦Ó㬿´ÁËʹÎÒ»ÐÈ»´óÎò¡£
ÔÚ½Ó¿ÚÖУ¬ËùÓеķ½·¨¶¼ÊÇpublic µ±È»ÔÚ½Ó¿ÚÖÐÒ²¿ÉÒÔÓÐpublic static finalÊôÐÔ
ΪʲôʹÓýӿڣº
1½Ó¿ÚÊǶԿɲåÈëÐԵı£Ö¤
¶Ô¼Ì³ÐµÄ×ÓÀàÓÐÓ°Ï죬¶Ô³¬ÀàûÓÐÓ°Ï죬¼õÉÙñîºÏ¶È
2½Ó¿Ú£¨ÒÔ¼°³éÏóÀࣩÓÃÀ´ÉùÃ÷Ò»¸öÐ嵀 ......