欢迎来到天天文库
浏览记录
ID:58883012
大小:112.50 KB
页数:41页
时间:2020-09-30
《Java语言基础语法appt课件.ppt》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、Java程序设计JavaProgrammingFall,2007Contents(Chapter6inTextbook)DataTypes(数据类型)Operators(运算符)Expressions(表达式)Arrays(数组)包装器类字符串类名字含义控制流语句DatainJavaJavaisa“typed”language:EverydatavaluemusthaveatypeThetypegivesrulesforwhatvaluesareallowed,andwhatoperationscanbedonewiththevalues.Forthecomputer
2、,valuesofacertaintypeusuallytakeaknownamountofstoragespaceinmemoryDatainJavaPrimitivetypesAprimitivetyperepresentsasinglevalue,whichcannotbedecomposed.ReferencetypesThereferencetypesareclasstypes,interfacetypesandarraytypes.Variablesofthesetypescanrefertoobjectsofthecorrespondingtype.Li
3、terals(直接量)Literals—thewaythatconstantvaluesofthattypearewritten.referenceliteralsnullbooleanliteralstrueandfalsePrimitiveDataTypeJavahasanumberofpre-definedprimitivedatatypes.booleanBoolean(logical)values,eithertrueorfalsecharsinglecharactersbyte8-bitintegers(signed)short16-bitintegers
4、(signed)int32-bitintegers(signed)(e.g.3)long64-bitintegers(signed)float32-bitfloatingpointdouble64-bitfloatingpoint(e.g.3.0)TheBooleanTypeABooleanvariableisonewhichcanhaveonly2possiblevalues:trueorfalse.BooleanvariablesareusedwhenyouneedtodologicaltestsExample“IsXgreaterthan3?”x>3Typein
5、tAvariableoftypeintmaytakevaluesfrom–2147483648to2147483647.ExceedingtherangeoflegalvaluesresultsinOVERFLOW,arun-timeerror.Baseofthenumber:octal(8进制)—aleading0(zero)hexadecimal(16进制)—aleading0xor0Xdecimal(10进制)TypelongAvariableoftypelongmaytakevaluesfrom–9223372036854775808Lto9223372036
6、854775807L.Toindicatethedifferencebetweenanintconstantandalongconstant,thecharacterLisappendedExample1isoftypeint1LisoftypelongValuesoftypelongtakeuptwiceasmuchmemoryasvaluesoftypeint.Typedouble(Literals)Typedoublerepresents“real”numbersapproximatelyfrom-1.710308to1.710308with15accura
7、tesignificantdigits(有效数字).Whiletherearealotofdoublevalues,thesetoflegaldoublevaluesisstillfinite,andsotheyareonlyanapproximationtorealnumbers.Afteracomputation,thecomputerhastochoosetheclosestdoublevaluetoarealresult:thiscanintroduce“round-off”errors.Typedouble(Literals)Formato
此文档下载收益归作者所有