ï»??xml version="1.0" encoding="utf-8" standalone="yes"?>992tv在线观看免费进,欧美精品在线免费,亚洲人成77777男人http://www.aygfsteel.com/yglwxl/category/31645.htmlzh-cnSun, 13 Feb 2011 21:19:57 GMTSun, 13 Feb 2011 21:19:57 GMT60Observer模式在J2EE中的实现 [http://35java.com/zhibo/forum.php?mod=viewthread&tid=108&extra=page%3D3]http://www.aygfsteel.com/yglwxl/archive/2011/02/13/344203.htmlä¹?ji¨¦)å®?/dc:creator>ä¹?ji¨¦)å®?/author>Sun, 13 Feb 2011 11:24:00 GMThttp://www.aygfsteel.com/yglwxl/archive/2011/02/13/344203.htmlhttp://www.aygfsteel.com/yglwxl/comments/344203.htmlhttp://www.aygfsteel.com/yglwxl/archive/2011/02/13/344203.html#Feedback0http://www.aygfsteel.com/yglwxl/comments/commentRss/344203.htmlhttp://www.aygfsteel.com/yglwxl/services/trackbacks/344203.html引言åQ?/span>
            è®¾è®¡æ¨¡å¼æ˜¯ç»éªŒçš„æ–‡æ¡£åŒ–。它是对被用来在特定场景下解决一般设计问题的¾cÕd’Œç›æ€º’通信的对象的描述。更通俗的来è¯ß_(d¨¢)¼Œå®ƒæ˜¯ä¸€ä¸ªé—®é¢?解决æ–ÒŽ(gu¨©)¡ˆå¯V€‚一旦我们掌握了设计模式åQŒå°±½{‰äºŽæ‹¥æœ‰äº†ä¸€æ”¯å¼ºæœ‰åŠ›çš„ä¸“å®‰™˜Ÿä¼ã€‚它甚至能够佉K¢å‘对象的新手利用前ähçš„ç»éªŒæ‰¾å‡ø™Œè´£æ˜Ž¼‹®çš„¾cÕd’Œå¯¹è±¡åQŒä»Žè€ŒèŽ·å¾—ä¼˜é›…çš„è§£å†³æ–ÒŽ(gu¨©)¡ˆã€‚由于设计模式也是重构的目标åQŒå¦‚果在设计的初期适当地引入设计模式,可以减少重构的工作量ã€?/span>
      ä½†æ˜¯åQŒæˆ‘们也不能陷入模式的陷阱,ä¸ÞZº†ä½¿ç”¨æ¨¡å¼è€ŒåŽ»å¥—æ¨¡å¼ï¼Œé‚£æ ·ä¼?x¨¬)é™·å…¥åŞ式主义。我们在使用模式的时候,一定要注意模式的意图(intentåQ‰ï¼Œè€Œä¸è¦è¿‡å¤šçš„åŽÕd…³æ³¨æ¨¡å¼çš„实现¾l†èŠ‚åQŒå› ä¸ø™¿™äº›å®žçŽ°ç»†èŠ‚åœ¨ç‰¹å®šæƒ…å†µä¸‹ï¼Œå¯èƒ½ä¼?x¨¬)å‘ç”Ÿä¸€äº›æ”¹å˜ã€‚ä¸è¦é¡½å›ºåœ°è®¤äØ“(f¨´)设计模式一书中的类图或实现代码ž®×ƒ»£è¡¨äº†æ¨¡å¼æœ¬èínã€?/span>
      ä¸‹é¢åQŒæˆ‘ä»¬æ¥è®¨è®ºä¸€ä¸‹äØ“(f¨´)什么要在分布式、多层系¾lŸä¸­ä½¿ç”¨Observer模式ã€?/span>
      

多层体系¾l“æž„åQˆmulti-tier architectureåQ‰ï¼š(x¨¬)
            ä¸‰å±‚体系¾l“构是多层体¾pȝ»“构中最½Ž€å•的一¿Uï¼Œå®ƒä¸€èˆ¬åŒ…括:(x¨¬)
      
  • 表示å±?presentation)åQçª—口、报è¡?
  • 业务逻辑å±?business logic)åQç®¡ç†ä¸šåŠ¡è¿‡½E‹çš„ä»ÕdŠ¡å’Œè§„åˆ™ã€‚å®ƒåˆå¯ä»¥ç»†åˆ†äØ“(f¨´)领域对象层(代表领域概念åQ‰å’ŒæœåŠ¡å±‚ï¼ˆæä¾›æ•°æ®åº“äº¤äº’ã€å®‰å…¨æ€§ã€æ‰“å°æŠ¥è¡¨ï¼‰ã€?/li>
  • 存储å±?storage)åQæŒä¹…化存储机制。如数据库服务器½{‰ã€?br style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; word-wrap: break-word; " />
              
图一åQšä¸‰å±‚体¾pȝ»“æž?/strong>
              
      è€ŒJava 2òq›_°ä¼ä¸šç‰ˆï¼ˆJ2EEåQ‰æ˜¯ä¸€¿Uåˆ©ç”¨Java 2òq›_°æ¥ç®€åŒ–诸多与多çñ”企业解决æ–ÒŽ(gu¨©)¡ˆçš„开发、部¾|²å’Œ½Ž¡ç†ç›¸å…³çš„复杂问题的体系¾l“构。它是开攄¡š„、基于标准的òq›_°åQŒç”¨ä»¥å¼€å‘、部¾|²å’Œ½Ž¡ç†N层结构、面向Web的,以服务器ä¸ÞZ¸­å¿ƒçš„企业¾U§åº”用ã€?/span>
      ä¸ÞZº†æ”¯æŒé¢†åŸŸå¯¹è±¡çš„复用,òq¶ä¸”佉K¢†åŸŸå¯¹è±¡çš„æŽ¥å£å˜æ›´æ‰€å¸¦æ¥çš„媄响最ž®åŒ–。我们将领域层(模型åQ‰å’Œè¡¨ç¤ºå±‚(视图åQ‰ç›¸åˆ†ç¦»ã€?/span>
      é‡‡ç”¨æ¨¡åž‹åQè§†å›¾æ¨¡å¼çš„æ„ä¹‰åœ¨äºŽåQ?/span>
      
  • 支持聚合度更高的模型定义åQŒä‹É模型的定义可以集中在领域˜q‡ç¨‹çš„定义,而不是图形界面上ã€?/li>
  • 允许ž®†æ¨¡åž‹å’Œç”¨æˆ·ç•Œé¢òq¶è¡Œå¼€å‘ã€?/li>
  • 使用æˆïL(f¨¥ng)•Œé¢çš„需求变化对领域层所造成的媄响最ž®åŒ–ã€?/li>
  • 允许建立与一个现有的领域层对象相˜qžæŽ¥çš„æ–°è§†å›¾åQŒåŒæ—¶ä¸å½±å“é¢†åŸŸå±‚ã€?/li>
  • 允许一个模型同时有多个视图åQŒä¾‹å¦‚ä‹É用SVG和表根{€?/li>
  • 允许模型层独立于用户界面层执行ã€?br style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; word-wrap: break-word; " />
      è€Œè¿™æ°æ°ä¸ŽObserver模式的意囄¡›¸åÕdˆã€‚因此我们有必要跨层来实现Observer模式ã€?/span>
      å…¶å®žåQŒåœ¨åº”用中更多的是采用MVC框架来架构整个企业应用的。在MVC框架中,Modelå’ŒView之间存在着依赖关系åQŒæ˜¯Observer模式的典型应用。当然MVC框架˜q˜åŒ…括其它模式如Composite模式和Strategy模式。在J2EEòq›_°ä¸­ï¼Œæˆ‘们可以把Web TieråQˆåŒ…括Jspå’Œserveletå’ŒJavaBeanåQ‰çœ‹ä½œæ˜¯è¡¨ç¤ºå±‚,EJB Tier看作是领域层。而controller可能跨距Web Tierå’?EJB Tierã€?/span>
      åœ¨Java¾cÕdº“中采用Java.util.Observable¾cÕd’ŒJava.util.Observer接口来实现Observer模式åQŒå®ƒä»¬åœ¨å•个的Java VM.中运行的很好åQŒä½†å¦‚果惛_œ¨EJB中ä‹É用它们就ä¼?x¨¬)有一些问题。这正如我们引言中提到的åQŒæ¨¡å¼çš„具体实现在特定情况下åQŒå¯èƒ½ä¼š(x¨¬)发生一些改变ã€?/span>
      

å€ég¼ é€’还是远½E‹å¼•用传递?
                    å€ég¼ é€’:(x¨¬)        
在Java RMI中要求所有的参数和返回类型是JAVA的基本类型或实现Java.io.Serilizable的对象。串行化对象通过å€ég¼ é€’(又名拯‚´ä¼ é€’)åQŒè€Œä¸æ˜¯å¼•用传递,˜q™æ„å‘³ç€åœ¨æŸä¸€å±‚ä¸­ä¸²è¡ŒåŒ–å¯¹è±¡çš„æ›´åÆˆä¸è‡ªåŠ¨åª„å“åˆ°å…¶å®ƒçš„å¯¹è±¡ã€?nbsp;     
              ˜qœç¨‹å¼•用传递:(x¨¬)        
对于EJB对象而言åQŒå®ƒç”׃¸¤ä¸ªæŽ¥å£ï¼ˆhome接口和remote接口åQ‰å’Œä¸€ä¸ªç±»¾l„成。容器会(x¨¬)æ ÒŽ(gu¨©)®ejb规范来生成实çŽîC¸Šé¢ä¸¤ä¸ªæŽ¥å£çš„¾c»ï¼ˆæˆ‘们分别¿UîCØ“(f¨´)xxxEJBHome对象和xxxEjbObject对象åQ‰ã€‚在较多的容器的实现æ–ÒŽ(gu¨©)¡ˆä¸­ï¼ŒxxxEJBHome对象使用了factory模式来创建xxxEjbObject对象åQ›xxxEjbObject对象则采用proxy模式åQŒä½œä¸ºxxxBean的代理类。在生成以上两个对象的同æ—Óž¼Œå®¹å™¨ä¼?x¨¬)从部çÖvæ–‡äšg中读取关于安全、事务、持久性等服务òq¶åœ¨xxxEjbObject对象和xxxEJBHome对象中添加以上服务的代码。而且xxxEJBHome对象和xxxEjbObject对象都是分布式对象,我们在此只讨论xxxEjbObject对象。所谓分布式对象åQŒä»Žæœ¬è´¨ä¸Šæ¥è®ÔŒ¼Œåˆ†äØ“(f¨´)3个部分:(x¨¬)object server、skeleton、stub。其中object serverå’Œskeleton位于服务器端åQŒè€Œstub位于客户端。Object server负责实现业务逻辑åQŒskeletonè´Ÿè´£marshalå’Œunmarshalæ–ÒŽ(gu¨©)³•½{‘֐ã€?nbsp;     
              
图二åQšåˆ†å¸ƒå¼å¯¹è±¡
              
      æ˜„¡„¶åQŒEJBçš„å®¢æˆøP¼ˆè°ƒç”¨EJB的对象)可以是ä“Q何对象,包括EJB和一般的Java¾cȝ”šè‡Ïx˜¯ç”¨ä“Q何语­a€å†™çš„corba客户端ã€?/span>
      ä»ŽEJB的客戯‚§†è§’来看的话,我们只能看到一个home接口、一个remote接口åQˆå¯¹äºŽå®žä½“bean的话åQŒè¿˜å¯ä»¥çœ‹è§ä¸€ä¸ªä¸»é”®ç±»åQŒè€Œbean¾cÕd¯¹å®¢æˆ·æ˜¯ä¸å¯è§çš„ï¼‰ã€‚ä½†æˆ‘ä»¬ä»Žä¸Šé¢çš„è®ø™¿°åQŒæˆ‘们可以知道,对于remote接口中地æ–ÒŽ(gu¨©)³•调用åQŒå®žé™…上是多态地调用XXX_Stub¾c…R€‚即XXX_Stub对象对客户具有可见性(但这¿Uå¯è§æ€§æ˜¯é€æ˜Žçš„,卛_®¢æˆ·ä¸çŸ¥é“˜q™ç§å¯è§æ€§çš„存在åQ‰ã€‚由于,XXX_Stub对象和Object Server实现了相同的接口åQŒåƈ且Object server真正实现了业务逻辑。所以,当在客户端调用XXX_Stub对象的方法时候,XXX_Stub对象通过socket通信机制ž®†æ–¹æ³•签名传¾l™XXX_Skeleton对象åQŒXXX_Skeleton对象在去委托Object Server完成业务处理逻辑。因此,Object Server本èín发生了改变。我们称XXX_Stub对象是Object Server对象的远½E‹å¼•用,òq¶è®¤ä¸ºå½“分布式对象作为参æ•îC¼ é€’的时候,是通过引用传递的åQˆä¼š(x¨¬)产生副作ç”?/span>

]]>
JavaBean PropertyChange 之设计模式Observer(è½?http://www.aygfsteel.com/yglwxl/archive/2011/02/13/344201.htmlä¹?ji¨¦)å®?/dc:creator>ä¹?ji¨¦)å®?/author>Sun, 13 Feb 2011 10:26:00 GMThttp://www.aygfsteel.com/yglwxl/archive/2011/02/13/344201.htmlhttp://www.aygfsteel.com/yglwxl/comments/344201.htmlhttp://www.aygfsteel.com/yglwxl/archive/2011/02/13/344201.html#Feedback0http://www.aygfsteel.com/yglwxl/comments/commentRss/344201.htmlhttp://www.aygfsteel.com/yglwxl/services/trackbacks/344201.html阅读全文

]]>
(è½?UML中类囑֮žä¾?/title><link>http://www.aygfsteel.com/yglwxl/archive/2011/02/12/344130.html</link><dc:creator>ä¹?ji¨¦)å®?/dc:creator><author>ä¹?ji¨¦)å®?/author><pubDate>Sat, 12 Feb 2011 05:02:00 GMT</pubDate><guid>http://www.aygfsteel.com/yglwxl/archive/2011/02/12/344130.html</guid><wfw:comment>http://www.aygfsteel.com/yglwxl/comments/344130.html</wfw:comment><comments>http://www.aygfsteel.com/yglwxl/archive/2011/02/12/344130.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.aygfsteel.com/yglwxl/comments/commentRss/344130.html</wfw:commentRss><trackback:ping>http://www.aygfsteel.com/yglwxl/services/trackbacks/344130.html</trackback:ping><description><![CDATA[<span style="font-size: 15px; line-height: 22px; "><span style="line-height: normal; word-spacing: 0px; font: normal normal normal 14px/22px georgia; text-transform: none; color: #4b4b4b; text-indent: 0px; white-space: normal; letter-spacing: normal; border-collapse: separate; text-align: left; orphans: 2; widows: 2; ">接口åQšç©ºå¿ƒåœ†+直线åQˆå”è€é¸­¾cÕd®žçŽîCº†‘讲ähè¯?#8217;åQ‰ï¼›<br style="line-height: 22px; " /> 依赖åQšè™š¾U?½Ž­å¤´åQˆåŠ¨ç‰©å’Œ½Iºæ°”的关¾p»ï¼‰åQ?br style="line-height: 22px; " /> å…Œ™”åQšå®ž¾U?½Ž­å¤´åQˆä¼é¹…需要知道气候才˜qç§»åQ‰ï¼›<br style="line-height: 22px; " /> 聚合åQšç©ºå¿ƒå››è¾¹åÅž+实线+½Ž­å¤´åQˆé›¾Ÿ¤å’Œå¤§é›çš„å…³¾p»ï¼‰åQ?br style="line-height: 22px; " /> 合成/¾l„合åQšå®žå¿ƒå››è¾¹åÅž+实线+½Ž­å¤´åQˆé¸Ÿå’Œç¿…膀的关¾p»ï¼‰åQ?br style="line-height: 22px; " /> 泛化/</span></span><span style="font-size: 15px; line-height: 22px; "><span style="line-height: normal; word-spacing: 0px; font: normal normal normal 14px/22px georgia; text-transform: none; color: #4b4b4b; text-indent: 0px; white-space: normal; letter-spacing: normal; border-collapse: separate; text-align: left; orphans: 2; widows: 2; ">¾l§æ‰¿</span></span><span style="font-size: 15px; line-height: 22px; "><span style="line-height: normal; word-spacing: 0px; font: normal normal normal 14px/22px georgia; text-transform: none; color: #4b4b4b; text-indent: 0px; white-space: normal; letter-spacing: normal; border-collapse: separate; text-align: left; orphans: 2; widows: 2; ">åQšç©ºå¿ƒä¸‰è§’åÅž+实线åQˆåŠ¨ç‰©å’Œé¸Ÿçš„¾l§æ‰¿å…³ç³»åQ‰ï¼›<br style="line-height: 22px; " /> 实现åQšç©ºå¿ƒä¸‰è§’åÅž+虚线åQˆå®žçŽ°å¤§é›é£ž¾˜”的接口åQ‰ï¼› <div style="font-family: Arial; word-wrap: break-word; word-break: break-all; visibility: visible !important; zoom: 1 !important; filter: none; font-size: 14px; line-height: 22px; "></div> <div style="font-family: Arial; word-wrap: break-word; word-break: break-all; visibility: visible !important; zoom: 1 !important; filter: none; font-size: 14px; line-height: 22px; "><strong style="line-height: 22px; ">UML¾cÕd›¾</strong>  </div> <dl style="line-height: 22px; "><dt style="line-height: 22px; "> <div style="font-family: Arial; word-wrap: break-word; word-break: break-all; visibility: visible !important; zoom: 1 !important; filter: none; font-size: 14px; line-height: 22px; "><span style="line-height: 22px; "> <div style="font-family: Arial; word-wrap: break-word; word-break: break-all; visibility: visible !important; zoom: 1 !important; filter: none; font-size: 14px; line-height: 22px; "><img title="UML中类囑֮žä¾?- Doom - 风云掠过" height="670" src="http://hiphotos.baidu.com/liang125353769/pic/item/b70db9225fc72a0393580758.jpg" width="703" style="line-height: 22px; border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; max-width: 100%; border-right-width: 0px; " alt="" /></div> 解释</span><span style="line-height: 22px; ">UML<span style="line-height: 22px; ">¾cÕd›¾åQ?/span></span></div> </dt><dt style="line-height: 22px; "> <div style="font-family: Arial; word-wrap: break-word; word-break: break-all; visibility: visible !important; zoom: 1 !important; filter: none; font-size: 14px; line-height: 22px; margin-left: 18pt; text-indent: -18pt; ">1.<span style="line-height: normal; ">      <span style="line-height: 19px; "> </span></span><span style="line-height: 22px; ">首先çœ?#8220;动物”矩åŞ框,它代表一个类。该¾cÕd›¾åˆ†äØ“(f¨´)三层åQŒç¬¬ä¸€å±‚显½Cºç±»çš„名¿UŽÍ¼Œå¦‚果是抽象类ž®Þp¦ç”¨æ–œä½“显½Cºã€‚第二层是类的特性,通常ž®±æ˜¯å­—æ®µå’Œå±žæ€§ã€‚ç¬¬ä¸‰å±‚æ˜¯ç±»çš„æ“ä½œï¼Œé€šå¸¸æ˜¯æ–¹æ³•å’Œè¡ŒäØ“(f¨´)ã€?/span></div> </dt><dt style="line-height: 22px; "> <div style="font-family: Arial; word-wrap: break-word; word-break: break-all; visibility: visible !important; zoom: 1 !important; filter: none; font-size: 14px; line-height: 22px; margin-left: 18pt; text-indent: -18pt; "><span style="line-height: 22px; ">   æ³¨æ„å‰é¢çš„ç¬¦åøP¼Œ‘</span>+<span style="line-height: 22px; ">’表示</span>public, ‘<span style="line-height: 22px; ">â€?/span>’<span style="line-height: 22px; "> </span><span style="line-height: 22px; ">表示</span>private, ‘#’<span style="line-height: 22px; ">表示</span>protected.   </div> <div style="font-family: Arial; word-wrap: break-word; word-break: break-all; visibility: visible !important; zoom: 1 !important; filter: none; font-size: 14px; line-height: 22px; "><img title="UML中类囑֮žä¾?- Doom - 风云掠过" src="http://hiphotos.baidu.com/liang125353769/pic/item/48598af20714951d342acc58.jpg" style="line-height: 22px; border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; max-width: 100%; cursor: pointer; border-right-width: 0px; " alt="" />                                           </div> </dt><dt style="line-height: 22px; "> <div style="font-family: Arial; word-wrap: break-word; word-break: break-all; visibility: visible !important; zoom: 1 !important; filter: none; font-size: 14px; line-height: 22px; margin-left: 18pt; text-indent: -18pt; ">2.<span style="line-height: normal; ">      <span style="line-height: 19px; "> </span></span>“<span style="line-height: 22px; ">飞翔</span>”<span style="line-height: 22px; ">矩åŞ框表½CÞZ¸€ä¸ªæŽ¥å£å›¾åQŒå®ƒä¸Žç±»å›„¡š„区别主要是顶端有ã€?/span>interface<span style="line-height: 22px; ">》显½Cºï¼Œ½W¬ä¸€è¡Œæ˜¯æŽ¥å£åç§°åQŒç¬¬äºŒè¡Œæ˜¯æŽ¥å£æ–¹æ³•。接口还有另一¿Uè¡¨½Cºæ–¹æ³•,俗称‹‚’棒¾p–表½Cºæ³•åQŒå°±æ˜¯å”è€é¸­¾cÕd®žçŽîCº†“讲ähè¯?#8221;的接口ã€?/span></div> </dt><dt style="line-height: 22px; "> <div style="font-family: Arial; word-wrap: break-word; word-break: break-all; visibility: visible !important; zoom: 1 !important; filter: none; font-size: 14px; line-height: 22px; margin-left: 18pt; text-indent: -18pt; "> <div style="font-family: Arial; word-wrap: break-word; word-break: break-all; visibility: visible !important; zoom: 1 !important; filter: none; font-size: 14px; line-height: 22px; "><img title="UML中类囑֮žä¾?- Doom - 风云掠过" height="159" src="http://hiphotos.baidu.com/liang125353769/pic/item/2f017cbee612fc4718d81f58.jpg" width="500" style="line-height: 22px; border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; max-width: 100%; cursor: pointer; border-right-width: 0px; " alt="" />              </div> </div> </dt><dt style="line-height: 22px; "> <div style="font-family: Arial; word-wrap: break-word; word-break: break-all; visibility: visible !important; zoom: 1 !important; filter: none; font-size: 14px; line-height: 22px; "> <div style="font-family: Arial; word-wrap: break-word; word-break: break-all; visibility: visible !important; zoom: 1 !important; filter: none; font-size: 14px; line-height: 22px; "> <div style="font-family: Arial; word-wrap: break-word; word-break: break-all; visibility: visible !important; zoom: 1 !important; filter: none; font-size: 14px; line-height: 22px; "><span style="line-height: 22px; color: #0000ff; ">interface</span><span style="line-height: 22px; color: #000000; "> IFly                              </span><span style="line-height: 22px; color: #0000ff; ">interface</span><span style="line-height: 22px; color: #000000; "> Ilanguage                              <br style="line-height: 22px; " /> {                                              {<br style="line-height: 22px; " />    </span><span style="line-height: 22px; color: #0000ff; ">void</span><span style="line-height: 22px; color: #000000; "> Fly();                                   <span style="line-height: 22px; "> </span></span><span style="line-height: 22px; color: #0000ff; ">void</span><span style="line-height: 22px; color: #000000; "> Speak();<br style="line-height: 22px; " /> }                                             }</span></div> </div> </div> </dt><dt style="line-height: 22px; "><br style="line-height: 22px; " /> </dt><dt style="line-height: 22px; "> <div style="font-family: Arial; word-wrap: break-word; word-break: break-all; visibility: visible !important; zoom: 1 !important; filter: none; font-size: 14px; line-height: 22px; margin-left: 18pt; text-indent: -18pt; ">3.<span style="line-height: normal; ">      <span style="line-height: 19px; "> </span></span><span style="line-height: 22px; ">动物åQŒé¸ŸåQŒé¸­åQŒå”è€é¸­ä»–们之间都是¾l§æ‰¿çš„å…³¾p»ï¼Œ<span style="line-height: 22px; color: red; "><span style="line-height: 22px; ">¾l§æ‰¿å…³ç³»ç”¨ç©ºå¿ƒä¸‰è§’åÅž</span>+<span style="line-height: 22px; ">实现来表½C?/span></span></span><span style="line-height: 22px; ">ã€?/span>   </div> </dt><dt style="line-height: 22px; "> <div style="font-family: Arial; word-wrap: break-word; word-break: break-all; visibility: visible !important; zoom: 1 !important; filter: none; font-size: 14px; line-height: 22px; margin-left: 18pt; text-indent: -18pt; "> <div style="font-family: Arial; word-wrap: break-word; word-break: break-all; visibility: visible !important; zoom: 1 !important; filter: none; font-size: 14px; line-height: 22px; "><img title="UML中类囑֮žä¾?- Doom - 风云掠过" src="http://hiphotos.baidu.com/liang125353769/pic/item/92d8300b954bc073b0351d58.jpg" style="line-height: 22px; border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; max-width: 100%; cursor: pointer; border-right-width: 0px; " alt="" /></div>                  </div> </dt><dt style="line-height: 22px; "><br style="line-height: 22px; " /> </dt><dt style="line-height: 22px; "> <div style="font-family: Arial; word-wrap: break-word; word-break: break-all; visibility: visible !important; zoom: 1 !important; filter: none; font-size: 14px; line-height: 22px; margin-left: 18pt; text-indent: -18pt; "><span style="line-height: 22px; ">4.“大雁”实现äº?#8220;飞翔”接口ã€?span style="line-height: 22px; color: red; "><span style="line-height: 22px; ">实现接口ç”?/span><span style="line-height: 22px; ">½Iºå¿ƒä¸‰è§’å½?/span>+<span style="line-height: 22px; ">虚线来表½C?/span></span></span><span style="line-height: 22px; ">。(<span style="line-height: 22px; background-color: yellow; ">注:(x¨¬)下面的图中应为空心三角åÅž</span>åQ?/span></div> </dt><dt style="line-height: 22px; "> <div style="font-family: Arial; word-wrap: break-word; word-break: break-all; visibility: visible !important; zoom: 1 !important; filter: none; font-size: 14px; line-height: 22px; margin-left: 18pt; text-indent: -18pt; "><span style="line-height: 22px; "><span style="line-height: 22px; color: #0000ff; "> <div style="font-family: Arial; word-wrap: break-word; word-break: break-all; visibility: visible !important; zoom: 1 !important; filter: none; font-size: 14px; line-height: 22px; "><img title="UML中类囑֮žä¾?- Doom - 风云掠过" src="http://hiphotos.baidu.com/liang125353769/pic/item/7cd2161f3a40815240341758.jpg" style="line-height: 22px; border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; max-width: 100%; cursor: pointer; border-right-width: 0px; " alt="" /></div> </span></span></div> </dt><dt style="line-height: 22px; "><br style="line-height: 22px; " /> </dt><dt style="line-height: 22px; "> <div style="font-family: Arial; word-wrap: break-word; word-break: break-all; visibility: visible !important; zoom: 1 !important; filter: none; font-size: 14px; line-height: 22px; "><span style="line-height: 22px; color: #0000ff; ">class</span><span style="line-height: 22px; color: #000000; "> Bird:Animal                      </span><span style="line-height: 22px; color: #0000ff; ">class</span><span style="line-height: 22px; color: #000000; "> WideGoose:IFly<br style="line-height: 22px; " /> {                                        {<br style="line-height: 22px; " />    </span><span style="line-height: 22px; color: #008000; ">//</span><span style="line-height: 22px; color: #008000; ">¾l§æ‰¿åŠ¨ç‰©¾c?nbsp;                                </span><span style="line-height: 22px; color: #008000; ">//</span><span style="line-height: 22px; color: #008000; ">实现飞翔接口</span><span style="line-height: 22px; color: #008000; "><br style="line-height: 22px; " /> </span><span style="line-height: 22px; color: #000000; ">}                                        }</span></div> </dt><dt style="line-height: 22px; "><br style="line-height: 22px; " /> </dt><dt style="line-height: 22px; "> <div style="font-family: Arial; word-wrap: break-word; word-break: break-all; visibility: visible !important; zoom: 1 !important; filter: none; font-size: 14px; line-height: 22px; margin-left: 18pt; text-indent: -18pt; ">5.<span style="line-height: normal; ">      <span style="line-height: 19px; "> </span></span><span style="line-height: 22px; ">企鹅与气候有很大的关¾p»ï¼Œä¼é¹…需è¦?#8220;知道”气候的变化åQŒéœ€è¦?#8220;了解”气候规律。当一个类“知道”另一个类æ—Óž¼Œå¯ä»¥ç”¨å…³è?/span>(association)<span style="line-height: 22px; ">关系ã€?span style="line-height: 22px; color: red; ">å…Œ™”关系用实¾U¿ç®­å¤´æ¥è¡¨ç¤º</span>ã€?/span><span style="line-height: 22px; ">  </span></div> </dt><dt style="line-height: 22px; "> <div style="font-family: Arial; word-wrap: break-word; word-break: break-all; visibility: visible !important; zoom: 1 !important; filter: none; font-size: 14px; line-height: 22px; margin-left: 18pt; text-indent: -18pt; "><span style="line-height: 22px; ">     <img title="UML中类囑֮žä¾?- Doom - 风云掠过" src="http://hiphotos.baidu.com/liang125353769/pic/item/568a4d1ed5a7eb47314e1558.jpg" style="line-height: 22px; border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; max-width: 100%; cursor: pointer; border-right-width: 0px; " alt="" /></span></div> </dt><dt style="line-height: 22px; "> <div style="font-family: Arial; word-wrap: break-word; word-break: break-all; visibility: visible !important; zoom: 1 !important; filter: none; font-size: 14px; line-height: 22px; margin-left: 18pt; text-indent: -18pt; "></div> </dt><dt style="line-height: 22px; "> <div style="font-family: Arial; word-wrap: break-word; word-break: break-all; visibility: visible !important; zoom: 1 !important; filter: none; font-size: 14px; line-height: 22px; "><span style="line-height: 22px; color: #0000ff; ">class</span><span style="line-height: 22px; color: #000000; "> Penguin :Bird<br style="line-height: 22px; " /> {<br style="line-height: 22px; " />    </span><span style="line-height: 22px; color: #0000ff; ">private</span><span style="line-height: 22px; color: #000000; "> Climate climate;</span><span style="line-height: 22px; color: #008000; ">//</span><span style="line-height: 22px; color: #008000; ">在企鹅Penguin中,引用到气候C(j¨©)limate对象</span><span style="line-height: 22px; color: #008000; "><br style="line-height: 22px; " /> </span><span style="line-height: 22px; color: #000000; ">}</span></div> </dt><dt style="line-height: 22px; "><br style="line-height: 22px; " /> </dt><dt style="line-height: 22px; "> <div style="font-family: Arial; word-wrap: break-word; word-break: break-all; visibility: visible !important; zoom: 1 !important; filter: none; font-size: 14px; line-height: 22px; margin-left: 18pt; text-indent: -18pt; ">6.<span style="line-height: normal; ">      <span style="line-height: 19px; "> </span></span><span style="line-height: 22px; ">“大雁”å’?#8220;雁群”˜q™ä¸¤ä¸ªç±»ã€‚大雁是¾Ÿ¤å±…动物åQŒæ¯åªå¤§é›éƒ½å±žäºŽä¸€ä¸ªé›¾Ÿ¤ï¼Œä¸€ä¸ªé›¾Ÿ¤å¯ä»¥æœ‰å¤šåªå¤§é›ã€‚所以它们之间就满èƒö聚合</span>(Aggregation)<span style="line-height: 22px; ">关系ã€?span style="line-height: 22px; color: red; "><span style="line-height: 22px; background-color: yellow; "><span style="line-height: 22px; color: #000000; "><span style="line-height: 22px; font-size: 10.5pt; ">聚合表示一¿Uå¼±çš?#8220;拥有”关系åQŒä½“现的æ˜?/span><span style="line-height: normal; ">A</span><span style="line-height: 22px; font-size: 10.5pt; ">对象可以包含</span><span style="line-height: normal; ">B</span><span style="line-height: 22px; font-size: 10.5pt; ">对象åQŒä½†</span><span style="line-height: normal; ">B</span><span style="line-height: 22px; font-size: 10.5pt; ">对象不是</span><span style="line-height: normal; ">A</span><span style="line-height: 22px; font-size: 10.5pt; ">对象的一部分ã€?/span></span></span></span></span><span style="line-height: 22px; "><span style="line-height: 22px; color: red; "><span style="line-height: 22px; ">聚合关系用空心的菱åÅž</span>+<span style="line-height: 22px; "> </span><span style="line-height: 22px; ">实线½Ž­å¤´è¡¨ç¤º</span></span></span><span style="line-height: 22px; ">ã€?/span></div> </dt><dt style="line-height: 22px; "> <div style="font-family: Arial; word-wrap: break-word; word-break: break-all; visibility: visible !important; zoom: 1 !important; filter: none; font-size: 14px; line-height: 22px; margin-left: 18pt; text-indent: -18pt; "><span style="line-height: 22px; ">    <span style="line-height: 22px; color: #0000ff; "> <div style="font-family: Arial; word-wrap: break-word; word-break: break-all; visibility: visible !important; zoom: 1 !important; filter: none; font-size: 14px; line-height: 22px; "><img title="UML中类囑֮žä¾?- Doom - 风云掠过" src="http://hiphotos.baidu.com/liang125353769/pic/item/6b9361c93d15b55a7e3e6f58.jpg" style="line-height: 22px; border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; max-width: 100%; cursor: pointer; border-right-width: 0px; " alt="" /></div> </span></span></div> </dt><dt style="line-height: 22px; "> <div style="font-family: Arial; word-wrap: break-word; word-break: break-all; visibility: visible !important; zoom: 1 !important; filter: none; font-size: 14px; line-height: 22px; margin-left: 18pt; text-indent: -18pt; "></div> <br style="line-height: 22px; " /> </dt><dt style="line-height: 22px; "> <div style="font-family: Arial; word-wrap: break-word; word-break: break-all; visibility: visible !important; zoom: 1 !important; filter: none; font-size: 14px; line-height: 22px; "><span style="line-height: 22px; color: #0000ff; ">class</span><span style="line-height: 22px; color: #000000; "> WideGooseAggregate<br style="line-height: 22px; " /> {<br style="line-height: 22px; " />    </span><span style="line-height: 22px; color: #0000ff; ">private</span><span style="line-height: 22px; color: #000000; "> WideGoose[] arrayWideGoose;<br style="line-height: 22px; " />    </span><span style="line-height: 22px; color: #008000; ">//</span><span style="line-height: 22px; color: #008000; ">在雁¾Ÿ¤WideGooseAggregate¾cÖM¸­åQŒæœ‰å¤§é›æ•°ç»„对象arrayWideGoose</span><span style="line-height: 22px; color: #008000; "><br style="line-height: 22px; " /> </span><span style="line-height: 22px; color: #000000; ">}</span></div> </dt><dt style="line-height: 22px; "><br style="line-height: 22px; " /> </dt><dt style="line-height: 22px; "> <div style="font-family: Arial; word-wrap: break-word; word-break: break-all; visibility: visible !important; zoom: 1 !important; filter: none; font-size: 14px; line-height: 22px; margin-left: 18pt; text-indent: -18pt; ">7.<span style="line-height: normal; ">      <span style="line-height: 19px; "> </span></span><span style="line-height: 22px; ">“é¸?#8221;å’?#8220;¾˜…膀”˜q™ä¸¤ä¸ªç±»ã€‚鸟和翅膀似整体和部分的关¾p»ï¼Œòq¶ä¸”¾˜…膀和鸟的生命周期是相同的,在这里鸟和其¾˜…膀ž®±æ˜¯åˆæˆå…³ç³»ã€?span style="line-height: 22px; background-color: yellow; "><span style="line-height: 22px; ">合成</span>(composition)<span style="line-height: 22px; ">是一¿Uå¼ºçš?#8220;拥有”关系åQŒä½“çŽîCº†ä¸¥æ ¼çš„部分和整体的关¾p»ï¼Œéƒ¨åˆ†å’Œæ•´ä½“的生命周期一æ ?/span></span></span><span style="line-height: 22px; ">ã€?span style="line-height: 22px; color: red; "><span style="line-height: 22px; ">合成关系用实心的的菱å½?/span>+<span style="line-height: 22px; ">实线½Ž­å¤´æ¥è¡¨½C?/span></span></span><span style="line-height: 22px; ">。另外,合成关系的连¾U¿ä¸¤ç«¯è¿˜æœ‰ä¸€ä¸ªæ•°å­?#8220;</span>1<span style="line-height: 22px; ">”和数å­?#8220;</span>2<span style="line-height: 22px; ">”åQŒï¼Œ˜q™è¢«¿UîCØ“(f¨´)基数。表明这一端的¾cÕd¯ä»¥æœ‰å‡ ä¸ªå®žä¾‹åQŒå¾ˆæ˜„¡„¶åQŒä¸€ä¸ªé¸Ÿåº”该有两支翅膀。如果一个类可能有无æ•îC¸ªå®žä¾‹åQŒåˆ™ž®Þq”¨“</span>n<span style="line-height: 22px; ">”来表½Cºã€‚关联关¾p»ï¼Œèšåˆå…³ç³»ä¹Ÿå¯ä»¥æœ‰åŸºæ•°çš„ã€?/span></div> </dt></dl><dl style="line-height: 22px; "><dt style="line-height: 22px; "><span style="line-height: 22px; color: #0000ff; "> <div style="font-family: Arial; word-wrap: break-word; word-break: break-all; visibility: visible !important; zoom: 1 !important; filter: none; font-size: 14px; line-height: 22px; "><img title="UML中类囑֮žä¾?- Doom - 风云掠过" src="http://hiphotos.baidu.com/liang125353769/pic/item/59df7916e3ad1b44c83d6d58.jpg" style="line-height: 22px; border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; max-width: 100%; cursor: pointer; border-right-width: 0px; " alt="" /></div> </span> <div style="font-family: Arial; word-wrap: break-word; word-break: break-all; visibility: visible !important; zoom: 1 !important; filter: none; font-size: 14px; line-height: 22px; "><span style="line-height: 22px; color: #0000ff; ">class</span><span style="line-height: 22px; color: #000000; "> Bird <br style="line-height: 22px; " /> {<br style="line-height: 22px; " />   </span><span style="line-height: 22px; color: #0000ff; ">private</span><span style="line-height: 22px; color: #000000; "> Wing wing;<br style="line-height: 22px; " />   </span><span style="line-height: 22px; color: #0000ff; ">public</span><span style="line-height: 22px; color: #000000; "> Bird()<br style="line-height: 22px; " />    {<br style="line-height: 22px; " />       wing</span><span style="line-height: 22px; color: #000000; ">=</span><span style="line-height: 22px; color: #0000ff; ">new</span><span style="line-height: 22px; color: #000000; "> Wing();<br style="line-height: 22px; " />     </span><span style="line-height: 22px; color: #008000; ">//</span><span style="line-height: 22px; color: #008000; ">在鸟Bird¾cÖM¸­åQŒåˆå§‹åŒ–æ—Óž¼Œå®žä¾‹åŒ–翅膀Wing,它们之间同时生成</span><span style="line-height: 22px; color: #008000; "><br style="line-height: 22px; " /> </span><span style="line-height: 22px; color: #000000; ">   }<br style="line-height: 22px; " /> }</span></div> </dt><dt style="line-height: 22px; "><br style="line-height: 22px; " /> </dt><dt style="line-height: 22px; "> <div style="font-family: Arial; word-wrap: break-word; word-break: break-all; visibility: visible !important; zoom: 1 !important; filter: none; font-size: 14px; line-height: 22px; margin-left: 18pt; text-indent: -18pt; ">8.<span style="line-height: normal; ">      <span style="line-height: 19px; "> </span></span><span style="line-height: 22px; ">“动物”ã€?#8220;æ°§æ°””ä¸?#8220;æ°?#8221;之间。动物有几大特征åQŒæ¯”如有新陈代谢åQŒèƒ½¾Jæ®–。而动物要有生命,需要氧气,水以å?qi¨¢ng)食物等。也ž®±æ˜¯è¯´åŠ¨ç‰©ä¾èµ–äºŽæ°§æ°”å’Œæ°´ã€‚å®ƒä»¬ä¹‹é—´æ˜¯<span style="line-height: 22px; color: red; "><span style="line-height: 22px; ">依赖关系</span>(Dependency),<span style="line-height: 22px; ">用虚¾U¿ç®­å¤´æ¥è¡¨ç¤º</span></span></span><span style="line-height: 22px; ">ã€?/span></div> </dt><dt style="line-height: 22px; "> <div style="font-family: Arial; word-wrap: break-word; word-break: break-all; visibility: visible !important; zoom: 1 !important; filter: none; font-size: 14px; line-height: 22px; margin-left: 18pt; text-indent: -18pt; "></div> </dt><dt style="line-height: 22px; "> <div style="font-family: Arial; word-wrap: break-word; word-break: break-all; visibility: visible !important; zoom: 1 !important; filter: none; font-size: 14px; line-height: 22px; margin-left: 18pt; text-indent: -18pt; "><span style="line-height: 22px; "><span style="line-height: 22px; color: #0000ff; "> <div style="font-family: Arial; word-wrap: break-word; word-break: break-all; visibility: visible !important; zoom: 1 !important; filter: none; font-size: 14px; line-height: 22px; "><img title="UML中类囑֮žä¾?- Doom - 风云掠过" src="http://hiphotos.baidu.com/liang125353769/pic/item/8167d70857ae0c823ac76358.jpg" style="line-height: 22px; border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; max-width: 100%; cursor: pointer; border-right-width: 0px; " alt="" /></div> </span></span></div> </dt><dt style="line-height: 22px; "> <div style="font-family: Arial; word-wrap: break-word; word-break: break-all; visibility: visible !important; zoom: 1 !important; filter: none; font-size: 14px; line-height: 22px; margin-left: 18pt; text-indent: -18pt; "></div> <br style="line-height: 22px; " /> </dt><dt style="line-height: 22px; "> <div style="font-family: Arial; word-wrap: break-word; word-break: break-all; visibility: visible !important; zoom: 1 !important; filter: none; font-size: 14px; line-height: 22px; "><span style="line-height: 22px; color: #0000ff; ">abstract</span> <span style="line-height: 22px; color: #0000ff; ">class</span><span style="line-height: 22px; color: #000000; "> Animal<br style="line-height: 22px; " /> {<br style="line-height: 22px; " />    </span><span style="line-height: 22px; color: #0000ff; ">public</span><span style="line-height: 22px; color: #000000; "> bolism(Oxygen oxygen,Water water)<br style="line-height: 22px; " />     {<br style="line-height: 22px; " />     } <br style="line-height: 22px; " /> }</span></div> </dt></dl></span></span> <img src ="http://www.aygfsteel.com/yglwxl/aggbug/344130.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.aygfsteel.com/yglwxl/" target="_blank">ä¹?ji¨¦)å®?/a> 2011-02-12 13:02 <a href="http://www.aygfsteel.com/yglwxl/archive/2011/02/12/344130.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Bitwise operators and Shift operatorshttp://www.aygfsteel.com/yglwxl/archive/2008/05/20/201630.htmlä¹?ji¨¦)å®?/dc:creator>ä¹?ji¨¦)å®?/author>Tue, 20 May 2008 05:22:00 GMThttp://www.aygfsteel.com/yglwxl/archive/2008/05/20/201630.htmlhttp://www.aygfsteel.com/yglwxl/comments/201630.htmlhttp://www.aygfsteel.com/yglwxl/archive/2008/05/20/201630.html#Feedback0http://www.aygfsteel.com/yglwxl/comments/commentRss/201630.htmlhttp://www.aygfsteel.com/yglwxl/services/trackbacks/201630.html 按位˜q›è¡Œä¸Žè¿½Ž?åQ?&
按位˜q›è¡Œæˆ–运½Ž?åQ?|
按位˜q›è¡Œä½å¼‚˜qç®—åQ?^
按位˜q›è¡Œå–反˜qç®—åQ?~
按位˜q›è¡Œå¾ªçŽ¯å·¦ç§»åQ?lt;<åQŒè¿½Ž—符左侧对象左移由右侧指定的位数åQŒä½Žä½è¡¥0åQŒæœ€é«˜ä½æŠ›å¼ƒã€‚带½W¦å·çš„å·¦¿UÖM½˜qç®—相当于对左操作数˜q›è¡Œä¹?˜qç®—ã€?
按位˜q›è¡Œå¾ªçŽ¯å³ç§»åQ?gt;>åQŒè¿½Ž—符左侧对象右移由右侧指定的位数åQŒè‹¥å€égØ“(f¨´)正,在最高位插入0åQŒè‹¥å€égØ“(f¨´)负,在最高位插入1åQŒå³¿UÕd…¥çš„æœ€é«˜ä½å’ŒåŽŸæœ€é«˜ç¬¦å·ä½ç›¸åŒã€‚å¸¦½W¦å·çš„右¿UÖM½˜qç®—相当于对左边的运½Ž—对象进行除2˜qç®—ã€?
按位˜q›è¡Œæ— ç¬¦å·å³¿U»ï¼š(x¨¬)>>>åQŒæ— è®ø™¿½Ž—符左边的运½Ž—对象取值正负,都在高位插入0åQŒå³¿UÕd…¥ä½å§‹¾lˆè¡¥0.
要注意是没有按位˜q›è¡Œæ— ç¬¦å·å·¦¿Uȝš„。位˜qç®—½W¦çš„æ“ä½œæ•°åªèƒ½æ˜¯æ•´æ•°åQŒchar,byte,short,
intå’Œlong,˜q›è¡Œä½è¿½Ž—æ—¶åQŒæ€ÀL˜¯å…ˆå°†å­—符型倹{€å­—èŠ‚åž‹å€¼å’ŒçŸ­æ•´åž‹å€ÆD{æ¢äØ“(f¨´)整型再进行位˜qç®—。位˜qç®—½W¦æ¸¸æ ‡çš„æ“ä½œæ•°ç”¨äºŽæŒ‡å®šç§»åŠ¨çš„ä½æ•°åQŒæŒ‰è§„定其不应超˜q‡å·¦ä¾§æ•°çš„进制表½CÞZ½æ•°ã€?
The bitwise operators allow you to manipulate individual bits in an integral primitive data type.Bitwise operators perform Boolean algebra on the corresponding bits in the two arguments to produce the result. The bitwise operators come from C’s low-level orientation, where you often manipulate hardware
directly and must set the bits in hardware registers. Java was originally designed to be embedded in TV set-top boxes, so this low-level orientation still made sense. However, you probably won’t use the bitwise operators much.
The bitwise AND operator (&) produces a one in the output bit if both input bits are one; otherwise, it produces a zero.
The bitwise OR operator (|) produces a one in the output bit if either input bit is a one and produces a zero only if both input bits are zero.
The bitwise EXCLUSIVE OR, or XOR (^), produces a one in the output bit if one or the other input bit is a one, but not both.
The bitwise NOT (~, also called the ones complement operator) is a unary operator; it takes only one argument. (All other bitwise operators are binary operators.) Bitwise NOT produces the opposite of the input bit—a one if the input bit is zero, a zero if the input bit is one.

]]>
Special case: primitive typeshttp://www.aygfsteel.com/yglwxl/archive/2008/05/20/201623.htmlä¹?ji¨¦)å®?/dc:creator>ä¹?ji¨¦)å®?/author>Tue, 20 May 2008 05:12:00 GMThttp://www.aygfsteel.com/yglwxl/archive/2008/05/20/201623.htmlhttp://www.aygfsteel.com/yglwxl/comments/201623.htmlhttp://www.aygfsteel.com/yglwxl/archive/2008/05/20/201623.html#Feedback0http://www.aygfsteel.com/yglwxl/comments/commentRss/201623.htmlhttp://www.aygfsteel.com/yglwxl/services/trackbacks/201623.htmlSpecial case: primitive types

Java determines the size of each primitive type. These sizes don’t change from one machine

architecture to another as they do in most languages. This size invariance is one reason Java

programs are more portable than programs in most other languages.

 

 

All numeric types are signed, so don’t look for unsigned types.

The size of the boolean type is not explicitly specified; it is only defined to be able to take the literal values true or false.

The “wrapper” classes for the primitive data types allow you to make a non-primitive object on the heap to represent that primitive type. For example:

char c = 'x';

Character ch = new Character(c);

Or you could also use:

Character ch = new Character('x');

Java SE5 autoboxing will automatically convert from a primitive to a wrapper type:

Character ch = 'x';

and back:

char c = ch;

The reasons for wrapping primitives will be shown in a later chapter.

High-precision numbers

Java includes two classes for performing high-precision arithmetic: BigInteger and

BigDecimal. Although these approximately fit into the same category as the “wrapper” classes, neither one has a primitive analogue.

Both classes have methods that provide analogues for the operations that you perform on

primitive types. That is, you can do anything with a BigInteger or BigDecimal that you can with an int or float, it’s just that you must use method calls instead of operators. Also, since there’s more involved, the operations will be slower. You’re exchanging speed for accuracy.

BigInteger supports arbitrary-precision integers. This means that you can accurately represent integral values of any size without losing any information during operations.

BigDecimal is for arbitrary-precision fixed-point numbers; you can use these for accurate

monetary calculations, for example.

 

OX123åQ?/span>1×162åQ?/span>2×161åQ?/span>3×160



]]>
整型数据http://www.aygfsteel.com/yglwxl/archive/2008/05/20/201617.htmlä¹?ji¨¦)å®?/dc:creator>ä¹?ji¨¦)å®?/author>Tue, 20 May 2008 05:10:00 GMThttp://www.aygfsteel.com/yglwxl/archive/2008/05/20/201617.htmlhttp://www.aygfsteel.com/yglwxl/comments/201617.htmlhttp://www.aygfsteel.com/yglwxl/archive/2008/05/20/201617.html#Feedback0http://www.aygfsteel.com/yglwxl/comments/commentRss/201617.htmlhttp://www.aygfsteel.com/yglwxl/services/trackbacks/201617.html 1.十进åˆ?br /> 2.å…«è¿›åˆÓž¼Œä»¥o开头O123åQ?×82åQ?×81åQ?×80åQå˜q›åˆ¶çš?3
3.十六˜q›åˆ¶ åQŒä»¥oxå¼€å¤?nbsp; OX123åQ?/span>1×162åQ?/span>2×161åQ?/span>3×160



]]>
Introduction to Objectshttp://www.aygfsteel.com/yglwxl/archive/2008/05/20/199515.htmlä¹?ji¨¦)å®?/dc:creator>ä¹?ji¨¦)å®?/author>Tue, 20 May 2008 05:10:00 GMThttp://www.aygfsteel.com/yglwxl/archive/2008/05/20/199515.htmlhttp://www.aygfsteel.com/yglwxl/comments/199515.htmlhttp://www.aygfsteel.com/yglwxl/archive/2008/05/20/199515.html#Feedback0http://www.aygfsteel.com/yglwxl/comments/commentRss/199515.htmlhttp://www.aygfsteel.com/yglwxl/services/trackbacks/199515.html1.The hidden implementation
The goal of the class creator is to build a class that exposes only what is necessary to the client programmer and keeps everything else hidden. Why?
(1)Becuase if it is hidden, the client programmer can't access it, which means that the class creator can change the hidden portion at will withou worring about the impact on anyone else.
(2)The hidden portion usually reprsents the tender insides of an object that could easily be corrupted by a careless or uninformed client programmer, so hiding the implementation reduces program bugs.

2.Reusing the implementation
The simplest way to reuse a class is to just use an object of that class directly, but you can also place an object of that class inside a new class. We call this "creating a member object." Your new class can be made up of any mumber and type of other objectss, in any combination that you need to achieve the fuctionality desired in your new class. Because you are composing a new class from existing classes, this conception is called composition. Compositon is often referred to as a "has-a" relationship, as "A car has an engine."
Because inheritance is so important in OOP, it is often highly emphasized, and the new programmer can get the idea that inheritance should be used everywhere. This can result in awkward and overly complicated designs. Instead, you should first look to composition when creating new classes, since it is simpler and more flexible. If you take this approach,your designer will be cleaner. Once you have had some experience, it will be reasonably obvious when you need inheritance.

3.Inheritance
You have two ways to differentiate your new derived class from the original base class.
The first is quite straightforward: You simply add brand new methods to the derived class. This means that the base class simply didn't as much as you wanted it to, so you added more methods. This simple and primitive use for inheritance is, at times, the perfect solution to your problem. However, you should look closely for the posiblilty that your base class might also need these additional methods. This process of discovery and iteration of your design happens regularly in OOP.
The second and more important way to differentiate your new class is to change the behavior of an existing base-class method. This is referred to as overriding that method. To override a method, you simply create a new definition for the method in the derived class. You are saying, "I am using the same interface method here, but I want it to do something different for my new type."

4.Is-a vs. is-like-a relationships

5.Interchangeable objects with polymorphism

6The single rooted hierarchy
All objects have a single rooted hierarchy can be guaranteed to have certain functionality. You know you can perform certain basic operations on every object in your system. All objects can easy be created on the heap, and argument passing is greatly simplified.
A single rooted hierarchy makes it much easier to implement a garbage collector, which is one of the fundamental improvements of Java over C++. And since information about the type of an object is guaranteed to be in all objects, you'll never end up with an object whose type you cannot determine. This is especially important with system-level operations, such as exception handling, and to allow greater flexibility in programming.

7.Containers

8.Parameterized types(generics)
One of the big changes in Java SE5 is the addition of parameterized types, called generics in java. you will recongize the use of generics by angle brackets with types inside.

9.Object creation & lifetime
How can you possibly know when to destroy the objects?
(1).C++ takes the approach that control of efficiency is the most important issue, so it give the programmer a choice.
(2).Java, in heap

10 Exception handling: dealing with errors

























]]>
java byte¾cÕdž‹ä¸ÞZ»€ä¹ˆæ˜¯åQ?27—â€?åQ?28åQ?/title><link>http://www.aygfsteel.com/yglwxl/archive/2008/05/20/201595.html</link><dc:creator>ä¹?ji¨¦)å®?/dc:creator><author>ä¹?ji¨¦)å®?/author><pubDate>Tue, 20 May 2008 04:48:00 GMT</pubDate><guid>http://www.aygfsteel.com/yglwxl/archive/2008/05/20/201595.html</guid><wfw:comment>http://www.aygfsteel.com/yglwxl/comments/201595.html</wfw:comment><comments>http://www.aygfsteel.com/yglwxl/archive/2008/05/20/201595.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.aygfsteel.com/yglwxl/comments/commentRss/201595.html</wfw:commentRss><trackback:ping>http://www.aygfsteel.com/yglwxl/services/trackbacks/201595.html</trackback:ping><description><![CDATA[所有的整数¾cÕdž‹åQˆé™¤äº†char ¾cÕdž‹ä¹‹å¤–åQ‰éƒ½æ˜¯æœ‰½W¦å·çš„æ•´æ•?br /> <br /> 因䨓(f¨´)åQ?javaçš„byteæ˜?bitåQˆä½åQ‰ï¼Œž®±æ˜¯8ä¸?/1 来表½Cºã€?br /> 但是½W¬ä¸€ä½æ˜¯½W¦å·ä½ï¼Œè¡¨ç¤ºæ­£æ•°˜q˜æ˜¯è´Ÿæ•°ã€‚所以:(x¨¬)<br /> 0000 0001表示1åQ?nbsp;    åQ?×  <span style="font-size: 10.5pt; font-family: Georgia">2<sup>0</sup></span>åQ?br /> 0000 0000表示0åQ?nbsp;    åQ?×  <span style="font-size: 10.5pt; font-family: Georgia">2<sup>0</sup></span>åQ?br /> <br /> 计算æœÞZ¸­è´Ÿæ•°çš„二˜q›åˆ¶ç æ˜¯æ˜¯è´Ÿæ•°çš„¾lå¯¹å€¼å–反,然后åŠ?.<br /> 例如åQ?的二˜q›åˆ¶åQ?br /> åQ?的绝对值是1åQ?000 0001åQ?<br /> 取反是(1111 1110åQ?<br /> 再加 1åQ?000 0001 åQ‰ï¼›<br /> ¾l“果是(1111 1111åQ?br /> <br /> 要对一个负数的二进制进行解码,首先对其所有的位取反,然后åŠ?ã€?br /> 例如åQ?çš?nbsp;二进åˆ?nbsp;  åQ?111 1111åQ?br /> 取反åQ?nbsp; 0000 0000 æ˜?<br /> 再加1åQšï¼ˆ0åQ?åQ?åQ?br /> ½W¦å·ä½æ˜¯1åQŒæ˜¯è´Ÿæ•°åQŒæ‰€ä»¥æ˜¯åQ?<br /> <br /> 1000 0000 表示åQ?28åQ?nbsp;  åQˆè§£ç è¿‡½E‹ï¼š(x¨¬)位取反是0111 1111åQï¼ã€?27åQŒç„¶åŽåŠ 1åQï¼ã€?28åQŒç¬¦å·ä½ä¸?,是负敎ͼŒè¡¨ç¤ºåQ?28åQ?br /> <br /> <img src ="http://www.aygfsteel.com/yglwxl/aggbug/201595.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.aygfsteel.com/yglwxl/" target="_blank">ä¹?ji¨¦)å®?/a> 2008-05-20 12:48 <a href="http://www.aygfsteel.com/yglwxl/archive/2008/05/20/201595.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss> <footer> <div class="friendship-link"> <a href="http://www.aygfsteel.com/" title="狠狠久久亚洲欧美专区_中文字幕亚洲综合久久202_国产精品亚洲第五区在线_日本免费网站视频">狠狠久久亚洲欧美专区_中文字幕亚洲综合久久202_国产精品亚洲第五区在线_日本免费网站视频</a> </div> </footer> Ö÷Õ¾Ö©Öë³ØÄ£°å£º <a href="http://" target="_blank">¶«ÏçÏØ</a>| <a href="http://" target="_blank">Æ½ÈªÏØ</a>| <a href="http://" target="_blank">ͨ³ÇÏØ</a>| <a href="http://" target="_blank">¹ÅÕÉÏØ</a>| <a href="http://" target="_blank">×ÔÖÎÏØ</a>| <a href="http://" target="_blank">½­°²ÏØ</a>| <a href="http://" target="_blank">ÈéɽÊÐ</a>| <a href="http://" target="_blank">·áÕòÊÐ</a>| <a href="http://" target="_blank">Ì«°×ÏØ</a>| <a href="http://" target="_blank">ÐÝÄþÏØ</a>| <a href="http://" target="_blank">´ÈÀûÏØ</a>| <a href="http://" target="_blank">¸ßÐÛÊÐ</a>| <a href="http://" target="_blank">°ËËÞÏØ</a>| <a href="http://" target="_blank">ÆæÌ¨ÏØ</a>| <a href="http://" target="_blank">ºôÂêÏØ</a>| <a href="http://" target="_blank">ÓÀ¼ÎÏØ</a>| <a href="http://" target="_blank">¼¦Î÷ÊÐ</a>| <a href="http://" target="_blank">ºÓ±±Ê¡</a>| <a href="http://" target="_blank">°¢¿ËËÕÊÐ</a>| <a href="http://" target="_blank">ƽ¶ÈÊÐ</a>| <a href="http://" target="_blank">Áé´¨ÏØ</a>| <a href="http://" target="_blank">ÁÙÒÊÊÐ</a>| <a href="http://" target="_blank">ÁÉÄþÊ¡</a>| <a href="http://" target="_blank">¿ËÀ­ÂêÒÀÊÐ</a>| <a href="http://" target="_blank">»´ÑôÏØ</a>| <a href="http://" target="_blank">ºÍË³ÏØ</a>| <a href="http://" target="_blank">²ý¶¼ÏØ</a>| <a href="http://" target="_blank">¼¦¶«ÏØ</a>| <a href="http://" target="_blank">¹ðÁÖÊÐ</a>| <a href="http://" target="_blank">ºº¹ÁÇø</a>| <a href="http://" target="_blank">ÄÏÕÙÏØ</a>| <a href="http://" target="_blank">¹ãÎ÷</a>| <a href="http://" target="_blank">´ó·áÊÐ</a>| <a href="http://" target="_blank">¸·¿µÊÐ</a>| <a href="http://" target="_blank">¶þÁ¬ºÆÌØÊÐ</a>| <a href="http://" target="_blank">ÌìÆø</a>| <a href="http://" target="_blank">èëÄÏÏØ</a>| <a href="http://" target="_blank">¼ÎÏéÏØ</a>| <a href="http://" target="_blank">ãë´¨ÏØ</a>| <a href="http://" target="_blank">¹ðÑôÏØ</a>| <a href="http://" target="_blank">ÁúÖÝÏØ</a>| <script> (function(){ var bp = document.createElement('script'); var curProtocol = window.location.protocol.split(':')[0]; if (curProtocol === 'https') { bp.src = 'https://zz.bdstatic.com/linksubmit/push.js'; } else { bp.src = 'http://push.zhanzhang.baidu.com/push.js'; } var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(bp, s); })(); </script> </body>