资源描述:
《个人博客系统的设计与实现-毕业论文-外文文献-一切都是对象》由会员上传分享,免费在线阅读,更多相关内容在学术论文-天天文库。
1、外文文献原文EverythingIsanObject“Ifwespokeadifferentlanguage,wewouldperceiveasomewhatdifferentworld.”AlthoughitisbasedonC++,Javaismoreofa“pure”object-orientedlanguage.BothC++andJavaarehybridlanguages,butinJavathedesignersfeltthatthehybridizationwasnotasimportantasitwasinC+
2、+.Ahybridlanguageallowsmultipleprogrammingstyles;thereasonC++ishybridistosupportbackwardcompatibilitywiththeClanguage.BecauseC++isasupersetoftheClanguage,itincludesmanyofthatlanguage’sundesirablefeatures,whichcanmakesomeaspectsofC++overlycomplicated.TheJavalanguageas
3、sumesthatyouwanttodoonlyobject-orientedprogramming.Thismeansthatbeforeyoucanbeginyoumustshiftyourmindsetintoanobject-orientedworld(unlessit’salreadythere).ThebenefitofthisinitialeffortistheabilitytoprograminalanguagethatissimplertolearnandtousethanmanyotherOOPlanguag
4、es.Inthischapteryou’llseethebasiccomponentsofaJavaprogramandlearnthat(almost)everythinginJavaisanobject.YoumanipulateobjectswithreferencesEachprogramminglanguagehasitsownmeansofmanipulatingelementsinmemory.Sometimestheprogrammermustbeconstantlyawareofwhattypeofmanipu
5、lationisgoingon.Areyoumanipulatingtheelementdirectly,orareyoudealingwithsomekindofindirectrepresentation(apointerinCorC++)thatmustbetreatedwithaspecialsyntax?AllthisissimplifiedinJava.Youtreateverythingasanobject,usingasingleconsistentsyntax.Althoughyoutreateverythin
6、gasanobject,theidentifieryoumanipulateisactuallya“reference”toanobject.1Youmightimagineatelevision(theobject)andaremotecontrol(thereference).Aslongasyou’reholdingthisreference,youhaveaconnectiontothetelevision,butwhensomeonesays,“Changethechannel”or“Lowerthevolume,”w
7、hatyou’remanipulatingisthereference,whichinturnmodifiestheobject.Ifyouwanttomovearoundtheroomandstillcontrolthetelevision,youtaketheremote/referencewithyou,notthetelevision.Also,theremotecontrolcanstandonitsown,withnotelevision.Thatis,justbecauseyouhaveareferencedoes
8、n’tmeanthere’snecessarilyanobjectconnectedtoit.Soifyouwanttoholdawordorsentence,youcreateaStringreference:Strings;Buthereyou’vecrea