- 1、本文档共13页,可阅读全部内容。
- 2、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
- 3、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载。
- 4、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
In this chapter you will learn: How static methods and fields are associated with an entire class rather than specific instances of the class. To use common Math methods available in the Java API. To understand the mechanisms for passing information between methods. How to use random-number generation to implement game-playing applications. Including the declarationimport java.util.Scanner;allows the programmer to use Scanner instead of java.util.Scanner Java API documentation /j2se/5.0/docs/api/index.html Overview of packages in JDK 5.0 /j2se/5.0/docs/api/overview-summary.html To promote software reusability, every method should be limited to performing a single, well-defined task, and the name of the method should express that task effectively. Such methods make programs easier to write, debug, maintain and modify. A small method that performs one task is easier to test and debug than a larger method that performs many tasks. Class Math is part of the java.lang package, which is implicitly imported by the compiler, so it is not necessary to import class Math to use its methods. -Three ways to call a method: Use a method name by itself to call another method of the same class Use a variable containing a reference to an object, followed by a dot (.) and the method name to call a method of the referenced object Use the class name and a dot (.) to call a static method of a class - static methods cannot call non-static methods of the same class directly It is a syntax error to break a String literal across multiple lines in a program. If a String does not fit on one line, split the String into several smaller Strings and use concatenation to form the desired String. Confusing the + operator used for string concatenation with the + operator used for addition can lead to strange results. Java evaluates the operands of an operator from left to right. For example, if integer variable y has the value 5, the expression y + 2 = + y + 2 results in the string y + 2 = 52,
您可能关注的文档
- Tim Aitmant.aitman@csc.mrc.ac.uk课件.ppt
- Tips & TricksTips and Tricks for CodeSmith 3.0课件.ppt
- Tom RinkTom WhittakerPaolo AntonelliKevin Baggett课件.ppt
- TONGFANG课件.ppt
- Topic 11 领导基础课件.ppt
- Topic 14 第十四讲:The Future of Library Technology图书馆科课件.ppt
- Topic 6 第六讲:The new generation of Library OPACs 新一课件.ppt
- Topic-C-EARTH课件.ppt
- TOPLUM VE HUKUK课件.ppt
- Total Recall for Ajax Applications – Firefox extension课件.ppt
- 四川省德阳市罗江中学2025届高三考前热身化学试卷含解析.doc
- 山东省枣庄现代实验学校2025届高三下学期第五次调研考试化学试题含解析.doc
- 吉林省长春市十一高中等九校教育联盟2025届高三一诊考试生物试卷含解析.doc
- 2025届江苏省盐城市伍佑中学高考仿真模拟化学试卷含解析.doc
- 2025届广西贺州中学高考冲刺押题(最后一卷)生物试卷含解析.doc
- 安徽省池州市贵池区2025届高三第一次模拟考试生物试卷含解析.doc
- 宁夏银川一中2025届高三(最后冲刺)化学试卷含解析.doc
- 广东省广州市增城区四校联考2025届高考压轴卷化学试卷含解析.doc
- 2025届邯郸市第一中学高考生物必刷试卷含解析.doc
- 2025届安徽省安庆市石化第一中学高考仿真卷化学试卷含解析.doc
文档评论(0)