Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

·¢ÏÖÒ»¸öc++¶à̬Óëjava¶à̬²»Í¬µÄµØ·½

¸Õ¸Õ¿´µ½Ò»ÆªÎÄÕÂÌá³öc++¶à̬Óëjava¶à̬²»Í¬µÄµØ·½£¬»ù±¾Òâ˼ÈçÏ£º
Çë¿´C++´úÂ룺
class Base
{
public:
 Base()
 {
  init(); 
 }
 virtual ~Base() {}
protected:
 int value;
 virtual void init() 
 { 
  value = 100;     
 }
};
class Derived : public Base
{
public:
 Derived()
 {
  init();
 }
protected:
 void init() 
 {
  cout << "value = " << value << endl;
  // ×öһЩ¶îÍâµÄ³õʼ»¯¹¤×÷ 
 }
};
int main(int argc, char* argv[])
{
 Base* pb;
 pb = new Derived();
 delete pb;
 return 0;
}
Ö´Ðнá¹ûÊÇ
value = 100
ÔÙ¿´java´úÂ룺
class Base
{
  public Base()
  {
    init();
  }
  protected int value;
  protected void init()
  {
         value = 100;  
  }
}
class Derived extends Base
{
  public Derived()
  {
    init();
  }
  protected void init()
  {
    System.out.println("value = " + value);
    // ×öһЩ¶îÍâµÄ³õʼ»¯¹¤×÷
  }
}
public class Test
{
  public static void main(String[] args)
  {
    Base base = new Derived();
  }
}
Ö´Ðнá¹ûÊÇ
value = 0
value = 0
ÔÚjavaÖÐ×ÓÀàµÄinit·½·¨ÖØдÁ˸¸ÀàµÄinit·½·¨£¬µ¼Ö²»ÄÜÕýÈ·Íê³É³õʼ»¯¡£¿´µ½ÕâÀïÎÒ˼¿¼ÁËһϣ¬ÓÉÓÚ×ÓÀàÖØдÁ˸¸ÀàµÄͬÃûº¯Êý£¬²Åµ¼Ö±¾Ó¦¸ÃÖ´Ðеĺ¯ÊýûÓÐÖ´ÐУ¬Èç¹ûÐ޸ĸ¸ÀàµÄ³õʼ»¯º¯Êý»òÕß×ÓÀàµÄ³õʼ»¯º¯Êý£¬Ê¹×ÓÀ಻»á·¢ÉúÖØд£¬ÊDz»ÊǾͲ»»á·¢ÉúÉÏÃæµÄÇé¿ö£¿»òÐí¼´Ê¹ÊÇ×ÓÀàÓ븸À࣬µ±Éæ¼°µ½¸÷×Եijõʼ»¯µÄµØ·½Ê±¾Í²»Ó¦¸ÃʹÓöà̬ÐÔ¡£


Ïà¹ØÎĵµ£º

Thinking in Java Ö®String ÕýÔò±í´ïʽ

       Ê²Ã´ÊÇÕýÔò±í´ïʽ£¿
       ÕýÔò±í´ïʽÊÇÒ»ÖÖÇ¿´ó¶øÁé»îµÄÎı¾´¦Àí¹¤¾ß¡£Ê¹ÓÃÕýÔò±í´ïʽ£¬ÎÒÃÇÄܹ»ÒÔ±à³ÌµÄ·½Ê½£¬¹¹Ô츴ÔÓµÄÎı¾Ä£Ê½£¬²¢¶ÔÊäÈëµÄ×Ö·û´®½øÐÐËÑË÷¡£Ò»µ©ÕÒµ½ÁËÆ¥ÅäÕâЩģʽµÄ²¿·Ö£¬Äã¾ÍÄܹ»ËæÐÄËùÓûµØ¶ÔËüÃǽøÐд¦Àí¡£ÕýÔò±í´ïÊ½Ì ......

JavaÈÕÆÚ¸ñʽ»¯³£Ó÷½·¨

JavaÖÐDateÀàÖеÄһЩÈÕÆÚ¸ñʽ»°·½·¨¶¼ÒѹýÆÚ£¬ËùÒÔ²»ÍƼöʹÓá£
Ò»°ã¸ñʽ»¯Ê±£¬³£Óõ½ÕâÁ½¸öÀࣺCalendar
ºÍSimpleDateFormat
£¬Ê¹Ó÷½·¨ÈçÏ£º
1.CalendarÀà
CalendarÀàÊÇabstractµÄ£¬ËùÒÔʵÀý»¯·½Ê½µÃÓþ²Ì¬·½·¨£º
Calendar c = Calendar.getInstance();£¬
´ËʱµÄÉú³ÉµÄʵÀýÒÀ¾ÝµÄÊǵ±Ç°ÏµÍ³Ê±¼ä£»c.setTime(java ......

java ´®¿Ú±à³Ì Ò»

1. SerialBean
SerialBeanÊDZ¾Àà¿âÓëÆäËûÓ¦ÓóÌÐòµÄ½Ó¿Ú¡£¸ÃÀà¿âÖж¨ÒåÁËSerialBeanµÄ¹¹Ôì·½·¨ÒÔ¼°³õʼ»¯´®¿Ú£¬´Ó´®¿Ú¶ÁÈ¡Êý¾Ý£¬Íù´®¿ÚдÈëÊý¾ÝÒÔ¼°¹Ø±Õ´®¿ÚµÄº¯Êý¡£¾ßÌå½éÉÜÈçÏ£º
public SerialBean(int PortID)
±¾º¯Êý¹¹ÔìÒ»¸öÖ¸ÏòÌض¨´®¿ÚµÄSerialBean£¬¸Ã´®¿ÚÓɲÎÊýPortIDËùÖ¸¶¨¡£PortID = 1 ±íʾCOM1£¬PortID = 2 ......

JavaÐòÁл¯¼òÃ÷¸ÅÒª

1. ¸ÅÄ ÐòÁл¯¾ÍÊǰѶÔÏó±ä³É¶ÔÏóÁ÷£¨È·ÇÐ˵ÊǰѶÔÏóµÄÊôÐÔдÈëÁ÷£©£¬Èç¹ûÐèÒª½ø¶ø¿ÉÒ԰ѶÔÏóÁ÷´æ³É¶þ½øÖÆÎļþ£»
2. Ä¿µÄ£º ÐòÁл¯µÄÄ¿µÄÊÇΪÁË·½±ãÓÀ¾Ã´æ´¢»òÕßÍøÂç´«Ê䣻
3. ÈçºÎʵÏÖ£º ½«ÀàʵÏÖSerializable½Ó¿Ú¼´¿É£¬ÎÞ±ØÐëʵÏֵķ½·¨£¬ÊµÏָýӿÚÖ»ÊÇΪÁ˱êʶ¸ÃÀà¿É±»ÐòÁл¯£»
4. £¨×ª£©ÆäËûÐèÒªÖªµÀµÄ£º
  ......

Java ¶àÏß³Ìͬ²½ÎÊÌâµÄ̽¾¿£¨Ò»¡¢Ï̵߳ÄÏÈÀ´ºóµ½£©

ÖÚËùÖÜÖª£¬ÔÚJava¶àÏ̱߳à³ÌÖУ¬Ò»¸ö·Ç³£ÖØÒªµÄ·½Ãæ¾ÍÊÇÏ̵߳Äͬ²½ÎÊÌâ¡£
¹ØÓÚÏ̵߳Äͬ²½£¬Ò»°ãÓÐÒÔϽâ¾ö·½·¨£º
1. ÔÚÐèҪͬ²½µÄ·½·¨µÄ·½·¨Ç©ÃûÖмÓÈësynchronized¹Ø¼ü×Ö¡£
תÔØ×¢Ã÷³ö´¦£ºhttp://x- spirit.javaeye.com/¡¢http: //www.blogjava.net/zhangwei217245/
2. ʹÓÃsynchronized¿é¶ÔÐèÒª½øÐÐͬ²½µÄ´úÂë¶Î½øÐÐ ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ