资源描述:
《《博爱立会廿五载主》PPT课件》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、JavaTutorialWriteOnce,RunAnywhereJava-GeneralJavais:platformindependentprogramminglanguagesimilartoC++insyntaxsimilartoSmalltalkinmentalparadigmPros:alsoubiquitoustonetCons:interpreted,andstillunderdevelopment(movingtarget)Java-GeneralJavahassomeinterestingfeatures:automatictypecheckin
2、g,automaticgarbagecollection,simplifiespointers;nodirectlyaccessiblepointertomemory,simplifiednetworkaccess,multi-threading!Compile-timeEnvironmentCompile-timeEnvironmentJavaBytecodesmovelocallyorthroughnetworkJavaSource(.java)JavaCompilerJavaBytecode(.class)JavaInterpreterJustinTimeCo
3、mpilerRuntimeSystemClassLoaderBytecodeVerifierJavaClassLibrariesOperatingSystemHardwareJavaVirtualmachineHowitworks…!Howitworks…!Javaisindependentonlyforonereason:OnlydependsontheJavaVirtualMachine(JVM),codeiscompiledtobytecode,whichisinterpretedbytheresidentJVM,JIT(justintime)compiler
4、sattempttoincreasespeed.Java-SecurityPointerdenial-reduceschancesofvirulentprogramscorruptinghost,Appletsevenmorerestricted-Maynotrunlocalexecutables,Readorwritetolocalfilesystem,Communicatewithanyserverotherthantheoriginatingserver.Object-OrientedJavasupportsOODPolymorphismInheritance
5、EncapsulationJavaprogramscontainnothingbutdefinitionsandinstantiationsofclassesEverythingisencapsulatedinaclass!JavaAdvantagesPortable-WriteOnce,RunAnywhereSecurityhasbeenwellthoughtthroughRobustmemorymanagementDesignedfornetworkprogrammingMulti-threaded(multiplesimultaneoustasks)Dynam
6、ic&extensible(loadsoflibraries)ClassesstoredinseparatefilesLoadedonlywhenneededBasicJavaSyntaxPrimitiveTypesandVariablesboolean,char,byte,short,int,long,float,doubleetc.Thesebasic(orprimitive)typesaretheonlytypesthatarenotobjects(duetoperformanceissues).Thismeansthatyoudon’tusethenewop
7、eratortocreateaprimitivevariable.Declaringprimitivevariables:floatinitVal;intretVal,index=2;doublegamma=1.2,brightnessbooleanvalueOk=false;InitialisationIfnovalueisassignedpriortouse,thenthecompilerwillgiveanerrorJavasetsprimitivevariablestozeroorfalseinthecaseofabooleanvariableAllob