Java基础数据库.doc

  1. 1、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。。
  2. 2、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载
  3. 3、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
Java基础数据库.doc

一、8种数据类?型与逻辑运?算 (1)Java有?8种数据类?型publi?c stati?c void main(Strin?g[] args) { //数据类型的?有4种 //字节类型 byte b = 2;// (8位) Syste?m.out.print?ln(字节型 +b); //短整型 short? s = 20;// (16位) Syste?m.out.print?ln(短整型 +s); //整型 int i = 200;// (32位) Syste?m.out.print?ln(整型: +i); //长整型 long g = 2000;// (64位) Syste?m.out.print?ln(长整型: +g); // 浮点类型的?有2个; // 以下2种类?型的相同点?都是存储浮?点数,不同点存储?范围由小到?大 // 默认使用双?精度浮点数? // 单精度浮点?数,注意:数字后面一?定要加F或?f,表示该数字?是floa?t类型,因为浮点数?默认是do?uble类?型 float? f = 1.2F;// (32位) Syste?m.out.print?ln(单精度: +f); // 双精度浮点?数 doubl?e d = 1.23;// (64位) Syste?m.out.print?ln(双精度: +d); // 2个特殊数?据类型 // 布尔类型 boole?an boo = true;//真 boo = false?;//假 Syste?m.out.print?ln(布尔类型: + boo); // 字符类型,注意:单个字符 char c = 你;// (16位) Syste?m.out.print?ln(字符类型: + c);} (2)Java的?比较运算符?与逻辑运算?符 publi?c stati?c void main(Strin?g[] args) { // 赋值运算符? int x = 10; int y = 20; int z = 30; int sum = x + y + z; Syste?m.out.print?ln(sum);60 int a = 2; a += 3;//a = a + 3; Syste?m.out.print?ln(a); //结果:5 //练习 int b = 10; short? s = 20; //注意:类型不一致?,首先低精度?向高精度转?,然后计算 //s = s + b; s += b;//自动转换类?型 Syste?m.out.print?ln(s); //(2)比较运算符?:最终结果一?定是布尔类?型(true/false?) Syste?m.out.print?ln(3 2); Syste?m.out.print?ln(3 = 2); //结果:true Syste?m.out.print?ln(3 2); //结果:false? Syste?m.out.print?ln(3 = 2); //结果:false? Syste?m.out.print?ln(3 == 2); //结果:false? Syste?m.out.print?ln(3 != 2); //结果:true // (3)三目操作符? int c = (3 2) ? 3 : 2; Syste?m.out.print?ln(c); // (4)算数运算符? Syste?m.out.print?ln(3 + 2); Syste?m.out.print?ln(2 - 3); //结果:-1 Syste?m.out.print?ln(2 * 3); //结果:6 Syste?m.out.print?ln(2 / 3); //结果:0 Syste?m.out.print?ln(2 % 3); //结果:2 // (5)自增自减 // ++在前,先自增,在参与运算? 在后,先参与运算?,在自减 int e = 2; Syste?m.out.print?ln(++e); int f = 3; Syste?m.out.print?ln(f--);

文档评论(0)

czy2014 + 关注
实名认证
内容提供者

该用户很懒,什么也没介绍

1亿VIP精品文档

相关文档