资源描述:
《java的面向对象基础教程(java object oriented basic course)》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、java的面向对象基础教程(Javaobjectorientedbasiccourse)ObjectorientedDay022012/4/1====================OOClassreferenceobjectconstructorMethod1objectoriented(OO)1)whatisObject(object),Objectmeaning:something,referstoaninstanceofspecificthings2)objectoriented,orientedtotherelationshipbetweenobjectivethings4)OOAo
2、bjectorientedanalysis/OODobjectorienteddesignHerecomestheguest(someonewhocomestoaguesttype)5)objectorientedconceptsAtype:nounconcepts,suchasguests,dishes,chefsBreference(variable):pronounsthatrefertospecificconceptualinstances,suchassomeone,specialsCobject(object):anindividualinstanceofaspecificconc
3、ept,suchasZhangSanfeng,theman,aplateofchickenDbehavior(method)Epolymorphism:behavior/reference,whichchangesinspecificsituationsAlamp:polymorphicPlay:changeaccordingtoobjectFencapsulation:anyobjectinstanceisencapsulatedaspossibletoreduceexposureEinheritance:theinheritancerelationofconcepts2Javatypes,
4、referencevariablesandheapobjects1)Javaclass,whichisusedtodescribethetypesofthings,suchasbooksTheconceptoflibrarymanagementsystem:BookBookThebookfeatures:ISBN,title,number,author,price...Class=type2)statementofclass:PublicclassBook{Longid;Stringname;StringISBN;//ISBNString[]authors;//AuthorDoublepric
5、e;}3)referencevariablesandobjectcreationprocess:MemorymanagementandallocationinAJava:StackisaJavausingmemoryarea,thewayitisused:LIFO(laterresidence)HeapisalsoamemoryareaforJava,whichdoesnotneedtobeallocatedrandomlyBlocalvariablesandheapobjectspatialallocationJavalocalvariablesareallocatedinthestack,
6、whichisassignedaccordingtothetypeofvariablesObjectsareallocatedinaheap,andspaceisallocatedaccordingtoclassproperties(instancevariables)CvariabletypesandallocationVariablesaredividedintobasictypesandreferencetypesThespacesizeofthebasictypevariable:thespacesizeofthebasictype,andthevalueisthebasictypeT
7、hevalueofThevalueofthereferencedvariableistheaddressvalueofanobject,andthereferencevariablereferstoaheapthroughtheaddressObject.Thevariablesizeandvaluemanagementofreferencetypevariablesaretransparent(