欢迎来到天天文库
浏览记录
ID:52374761
大小:354.06 KB
页数:25页
时间:2020-04-05
《《课流程控制》PPT课件.ppt》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、第二课《流程控制》目标掌握Java的编程规范掌握Java的关键字掌握Java的基本数据类型掌握Java的变量和常量定义掌握Java中的运算符掌握Java的程序控制流程2©2007iSoftStoneHoldingsLtd.AllRightsReserved.分号、块和空白在Java编程语言中,语句是一行由分号(;)终止的代码。例如:totals=a+b+c+d+e+f;一个块是以上括号和下括号为边界的语句集合。例如:x=y+1;y=x+1;Java程序中允许任意多的空白。3©2007iSoftSton
2、eHoldingsLtd.AllRightsReserved.标识符(命名)是赋予变量、类和方法的名称;且无最大长度可从一个字母、下划线(_)或美元符号($)开始;是大小写区别对待的。例如:identifieruserNameUser_name_sys_varl$change4©2007iSoftStoneHoldingsLtd.AllRightsReserved.Java关键字(了解)abstractdoimplementsprivatethrowBooleandoubleimportprotected
3、throwsbreakelseinstanceofpublictransientbyteextendsinreturntruecasefalseinterfaceshorttrycatchfinallongstaticvoidcharfinallynativesupervolatileclassfloatnewswitchwhilecontinuefornullsynchronizeddefaultifpackagethis5©2007iSoftStoneHoldingsLtd.AllRightsRese
4、rved.基本数据类型(8种)字符类char逻辑类boolean整数类byte,short,int,long浮点类double,float6©2007iSoftStoneHoldingsLtd.AllRightsReserved.逻辑类──booleanboolean数据类型有两种文字值:true和false。例如:booleantruth=true;上述语句声明变量truth为boolean类型,它被赋予的值为true。7©2007iSoftStoneHoldingsLtd.AllRightsReser
5、ved.文本类──char和StringChar代表一个16-bitUnicode字符;必须包含用单引号(’’)引用的文字;使用下列符号:‘a’‘t’一个制表符String不是一个原始数据类型,它是一个类;具有用双引号引用的文字:“ThisisaString..”可按如下情形使用:Stringgreeting=“GoodMorning!!”;Stringerr_meg=“recordnotfound!”;8©2007iSoftStoneHoldingsLtd.AllRightsReserved.整数
6、类──byte,short,int,long四个整数类型的长度和范围:8bitsbyte-27...27–116bitsshort-215...215–132bitint-231...231–164bitslong-263...263-19©2007iSoftStoneHoldingsLtd.AllRightsReserved.浮点──float和double浮点数据类型的长度范围:float32bits如:2.718Fdouble64bits如:123.4E+306D其中double为缺省值10©200
7、7iSoftStoneHoldingsLtd.AllRightsReserved.变量、声明和赋值publicclassAssign{publicstaticvoidmain(Stringargs[]){intx,y;floatz=3.414f;doublew=3.141;booleantruth=true;intnx=(int)z;charc='A';Stringstr;Stringstr1="bye";str="Hioutthere!";x=6;y=1000;}}11©2007iSoftStoneHo
8、ldingsLtd.AllRightsReserved.常量publicclassConstants{publicstaticvoidmain(String[]args){finaldoubleCM_PER_INCH=2.54;doublepaperWidth=8.5;doublepaperHeight=11;System.out.println("Papersizeincentimeters:"+paperWidth*CM_
此文档下载收益归作者所有