- 1、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。。
- 2、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载。
- 3、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
Chapter 7 Strings.ppt
Chapter 7 Strings To process strings using the String class, the StringBuffer class, and the StringTokenizer class. To use the String class to process fixed strings. To use static methods in the Character class. To use the StringBuffer class to process flexible strings. To use the StringTokenizer class to extract tokens from a string. To use the command-line arguments. The String Class Constructing a String: String message = Welcome to Java! String message = new String(Welcome to Java!“); String s = new String(); Obtaining String length and Retrieving Individual Characters in a string String String Concatenation (concat) Substrings (substring(index), substring(start, end)) Comparisons (equals, compareTo) String Conversions Finding a Character or a Substring in a String Conversions between Strings and Arrays Converting Characters and Numeric Values to Strings Constructing Strings Strings newString = new String(stringLiteral); ? String message = new String(Welcome to Java!); Since strings are used frequently, Java provides a shorthand notation for creating a string: String message = Welcome to Java!; Strings Are Immutable NOTE: A String object is immutable, whose contents cannot be changed. To improve efficiency and save memory, Java Virtual Machine stores two String objects into the same object, if the two String objects are created with the same string literal using the shorthand notation. Therefore, the shorthand notation is preferred to create strings. Strings Are Immutable, cont. NOTE: A string that is created using the shorthand notation is known as a canonical string. You can use the String’s intern method to return a canonical string, which is the same string that is created using the shorthand notation. Examples String s = Welcome to Java!; String s1 = new String(Welcome to Java!); String s2 = ern(); System.out.println(s1 == s is + (s1 == s)); System.out.println(s2 == s is + (s2 == s)); System.out.println(s1 == s2 is + (s1 == s2
您可能关注的文档
- 5.6.热力学第二定律的微观解释 能源和可持续发展.ppt
- 5.7《生活中的圆周运动》.ppt
- 5A, Fun with English, Yilin Edition.ppt
- 6.1 相数,组分数,自由度数.ppt
- 6.1 能源概述 6.1.1 能源的分类和能量的转化.ppt
- 6.2 80C51的串行口.ppt
- 6.2 化石燃料 6.2.1 煤炭.ppt
- 6.2 同步电动机的启动.ppt
- 6.2 正等轴测图.ppt
- 6.3 实数.ppt
- Chapter 7 Television and Cable.ppt
- Chapter 7 Tourism Marketing.ppt
- CHAPTER 7 USING CONSUMER LOANS.ppt
- Chapter 7 Vectors and the Geometry of Space.ppt
- Chapter 7 环境噪声影响评价.ppt
- Chapter 7- Management's Discussion and Analysis (MD&A) .ppt
- Chapter 7--Learning Objectives.ppt
- Chapter 7-2 Northern Hearth2. Southern New England.ppt
- Chapter 7. Kinetic Energy and Work.ppt
- Chapter 7. Risk and Term Structure of Interest Rates.ppt
文档评论(0)