资源描述:
《java最常见的几种基础程序》由会员上传分享,免费在线阅读,更多相关内容在工程资料-天天文库。
1、java最常见的几种基础程序Java(程序及语法)/**************************************************这是个最基本的JAVA程序,最基本的JAVA程序必须有一个类**************************************************///最基本的JAVA程序必须有一个类,在这里是clasbase01classbase01{//在JAVA中,程序的入口也为main函数//main()函数前的限制符顺序必须为publicstati
2、cvoid,参数必须为String类型的数组//以下写法将不被通过publicvoidstaticmain(String[]args){System.out.println("HelloWorld!");}}**********************************************************java源文件的命名规则在同一个JAVA文件中可以定义多个类,但是只有一个类能定义为public而且如果一个类被定义为public,这个文件的文件名必须和该public类的名字相同。对于
3、本类,文件必须命名为base02***********************************************************/classA{inta;};classB{intb;};publicclassbase02{otherstaffoftheCentre.Duringthewar,ZhuwastransferredbacktoJiangxi,andDirectorofthenewOfficeinJingdezhen,JiangxiCommitteeSecretary.Sta
4、rtingin1939servedasrecorderoftheWestNorthOrganization,SecretaryoftheSpecialCommitteeAfterthevictoryofthelongMarch,hehasbeentheNorthwestOfficeoftheFederationofStateenterprisesMinister,ShenmufuguSARmissions,DirectorofNingxiaCountypartyCommitteeSecretaryandr
5、ecorderoftheCountypartyCommitteeSecretary,Ministersandpublicstaticvoidmain(String[]args){System.out.println("HelloWorld!");}}Java(程序及语法3)classcode01{publicstaticvoidmain(String[]args){//JAVA的数据类型。请注意大小写//一个字节的整型bytee=3;System.out.println(e);//两个字节的整型short
6、h=4;System.out.println(h);//四个字节的整型intf=4;System.out.println(f);//八个字节的整型longg=5;System.out.println(g);//4个字节的浮点数floata=11.3f;System.out.println(a);//8个字节的浮点数(更加精确)doubleb=12.3d;System.out.println(b);//两个字节的单个字符。注意定义字符的时候不能用双引号,只能用单引号charc='s';Stringss="x
7、iongyong";System.out.println(c);//bool变量,用于判断真假。注意:true和false不能大写。otherstaffoftheCentre.Duringthewar,ZhuwastransferredbacktoJiangxi,andDirectorofthenewOfficeinJingdezhen,JiangxiCommitteeSecretary.Startingin1939servedasrecorderoftheWestNorthOrganization,Se
8、cretaryoftheSpecialCommitteeAfterthevictoryofthelongMarch,hehasbeentheNorthwestOfficeoftheFederationofStateenterprisesMinister,ShenmufuguSARmissions,DirectorofNingxiaCountypartyCommitteeSecretaryandrecorderoftheCoun