您好,欢迎光临本网站![请登录][注册会员]  
文件名称: ch02-primitive-data-definite-loops.pdf
  所属分类: Java
  开发工具:
  文件大小: 607kb
  下载次数: 0
  上传时间: 2019-09-14
  提 供 者: yhe***
 详细说明:java 基础入门学习1-18章节,连续上传。希望对大家有帮助Java' s primitive types primitive types: 8 simple types for numbers text, etc Java also has object types, which well talk about later Name Description Examples nt ntegers (upto231-1) 42,-3,0,926394 double real numbers (up to 10308 3.1,-0.25,9,4e3 char single text characters n boolean logical values true,fa⊥se Why does Java distinguish integers vs real numbers? Expressions expression: a value or operation that computes a value o Examples: (7+2)6/3 42 The simplest expression is a literal value A complex expression can use operators and parentheses Arithmetic operators operator: combines multiple values or expressions. addition subtraction(or negation) multiplication /。 division modulus(ak a remainder) As a program runs, its expressions are evaluated 1 +1 evaluates to 2 System. out. println(3 4)i prints 12 How would we print the text 3 4? Integer division with/ When we divide integers the quotient is also an integer 14/4is3,not3.5 3 52 4)14 10 45 27)1425 12 40 135 5 75 54 21 ● More examples 32/5 Is 6 84/10is8 156/100is1 Dividing by 0 causes an error when your program runs Integer remainder with o The o operator computes the remainder from integer division 14 Is 2 218%5is3 What is the result? 45 43 4)14 5)218 282 12 20 8820 2 11 15 Applications of o operator Obtain last digit of a number 230857 10 is 7 Obtain last 4 digits 658236489810000s6489 See whether a number is odd 2|s1,422s0 Precedence precedence: Order in which operators are evaluated Generally operators evaluate left-to-right 1-2-3is(1-2)-3 which is-4 But大/各 have a higher level of precedence than+ 1+3★4 s13 6+8/2 6 6+ 12 S 1 Parentheses can force a certain order of evaluation (1+3)大4 Is 1 Spacing does not affect order of evaluation 1+34-2 s11 Precedence examples 1大2+35 1+832 +3大5 1+2 大2 2 +15 1+ 2 3 Precedence questions What values result from the following expressions? 9/5 69520 7+65 7大6+5 248100/5 大 (5-7)大4 (18(17-12)) 10
(系统自动生成,下载前可以参看下载内容)

下载文件列表

相关说明

  • 本站资源为会员上传分享交流与学习,如有侵犯您的权益,请联系我们删除.
  • 本站是交换下载平台,提供交流渠道,下载内容来自于网络,除下载问题外,其它问题请自行百度
  • 本站已设置防盗链,请勿用迅雷、QQ旋风等多线程下载软件下载资源,下载后用WinRAR最新版进行解压.
  • 如果您发现内容无法下载,请稍后再次尝试;或者到消费记录里找到下载记录反馈给我们.
  • 下载后发现下载的内容跟说明不相乎,请到消费记录里找到下载记录反馈给我们,经确认后退回积分.
  • 如下载前有疑问,可以通过点击"提供者"的名字,查看对方的联系方式,联系对方咨询.
 输入关键字,在本站1000多万海量源码库中尽情搜索: