资源描述:
《java语言基础组成》由会员上传分享,免费在线阅读,更多相关内容在工程资料-天天文库。
1、第一个程序 //文件名HelloWorld.java //声明一个类 publicclassHelloWorld{ //声明一个方法 publicstaticvoidmain(Stringargs[]){//程序的入口 //输出 System.out.println(“helloworld!”); } } //例子 packageText; publicclassTest{ publicstaticvoidmain(Stringargs[]){ shortd=12;//短整型 Syst
2、em.out.println(d);//输出d longc=144L;//长整型,要加l System.out.println(c);//输出c intz=15;//整型 System.out.println(z);//输出z chare='我';//字符型“我” System.out.println(e);//输出e } } //无编译工具编译运行java程序 //路径是相对路径 编译java javac[java源程序名称。java]//一定要加上后缀名 //这个时候你会发现你的原程序
3、旁边多了一个.class文件,文件名和源文件名称相同 //有编译错误会提示 运行java java[java源程序名称]//不需要加后缀名,自动运行。class文件 //显示程序运行结果otherstaffoftheCentre.Duringthewar,ZhuwastransferredbacktoJiangxi,andDirectorofthenewOfficeinJingdezhen,JiangxiCommitteeSecretary.Startingin1939servedasrecorderoft
4、heWestNorthOrganization,SecretaryoftheSpecialCommitteeAfterthevictoryofthelongMarch,hehasbeentheNorthwestOfficeoftheFederationofStateenterprisesMinister,ShenmufuguSARmissions,DirectorofNingxiaCountypartyCommitteeSecretaryandrecorderoftheCountypartyCommitteeSec
5、retary,Ministersand1关键字java关键字概述 关键字是电脑语言里事先定义的,有特别意义的标识符,有时又叫保留字,还有特别意义的变量。 Java的关键字对java的编译器有特殊的意义,他们用来表示一种数据类型,或者表示程序的结构等,关键字不能用作变量名、方法名、类名、包名。 一个Java语言中的关键字,用在类的声明中来指明一个类是不能被实例化的,但是可以被其它类继承。一个抽象类可以使用抽象方法,抽象方法不需要实现,但是需要在子类中被实现。break 一个Java的关键字,用来改变程序执行流
6、程,立刻从当前语句的下一句开始执行从。如果后面跟有一个标签,则从标签对应的地方开始执行。case Java语言的关键字,用来定义一组分支选择,如果某个值和switch中给出的值一样,就会从该分支开始执行。catch Java的一个关键字,用来声明当try语句块中发生运行时错误或非运行时异常时运行的一个块。char Java语言的一个关键字,用来定义一个字符类型。 int Java语言的一个关键字,用来定义一个整型类型数据或变量。 for Java语言的一个关键字,是循环结构中经常使用的一个关键字,其形
7、式为: for(表达式1;表达式2;表达式3)otherstaffoftheCentre.Duringthewar,ZhuwastransferredbacktoJiangxi,andDirectorofthenewOfficeinJingdezhen,JiangxiCommitteeSecretary.Startingin1939servedasrecorderoftheWestNorthOrganization,SecretaryoftheSpecialCommitteeAfterthevictoryofth
8、elongMarch,hehasbeentheNorthwestOfficeoftheFederationofStateenterprisesMinister,ShenmufuguSARmissions,DirectorofNingxiaCountypartyCommitteeSecretaryandrecorderoftheCountypartyCommi