- 1、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。。
- 2、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载。
- 3、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
Liang, Introduction to Java Programming, Sixth Edition, (c) 2007 Pearson Education, Inc. All rights reserved. 0-13-222158-6 Objectives To use the String class to process fixed strings To use the Character class to process a single character To use the StringBuffer class to process flexible strings To learn how to pass strings to the main method from the command line To discover file properties, delete and rename files using the File class To write data to a file using the PrintWriter class To read data from a file using the Scanner class Introduction(P262 8.1) String are used often in programming. A String is a sequence of characters. In many language ,strings are treated as array of characters, but in Java a string is an Object. Strings Are Immutable(8.2.2) A String object is immutable; its contents cannot be changed. Does the following code change the contents of the string? String s = Java; s = s + HTML; Construct a String (1) To creating a string from a string literal (2) Since strings are used frequently, Java provides a shorthand initializer for creating a string: (3) Create a string from an array of characters Interned Strings String s1 = new String(welcome to java); String s2 = new String(welcome to java); System.out.println(s1==s2); Interned Strings(8.2.2) Since strings are immutable and are frequently used, to improve efficiency and save memory, the JVM uses a unique instance for string literals with the same character sequence. Such an instance is called interned. You can also use a String object’s intern method to return an interned string. Examples(8.2.2) Display: s1 == s is false s2 == s is true s == s3 is true Finding String Length(8.2.4) Definition: public int length() Retrieving Individual Character(8.2.4) Definition : public char charAt(int?index) Exercise 1 输入任意字符串,将其反向输出 Scanner input = new Scanner(System.in); String s = input.next(); 反向输出s Exercise 2(P270 listing8.1) 判断一个字符串是不是回文(palindrome)
您可能关注的文档
- Java 2实用教程课件(第3版第1章 Java 语言入门).ppt
- Java 2实用教程课件(第3版第4章 类、对象和接口).ppt
- Java 2实用教程课件(第3版第4章).ppt
- Java 2实用教程课件(第3版第5章 字符串).ppt
- Java 2实用教程课件(第3版第5章).ppt
- Java 2实用教程课件(第3版第6章).ppt
- Java 2实用教程课件(第3版第8章).ppt
- Java 2实用教程课件(第3版第9章).ppt
- Java 2实用教程课件(第3版第10章).ppt
- Java 2实用教程课件(第3版第13章).ppt
- 急性肾功能衰竭综合征的肾血管介入性诊治4例报告并文献复习.docx
- 基于血流动力学、镇痛效果分析右美托咪定用于老年患者髋部骨折术的效果.docx
- 价格打骨折 小心统筹车险.docx
- 交通伤导致骨盆骨折合并多发损伤患者一体化救治体系的效果研究.docx
- 多层螺旋CT与DR片诊断肋骨骨折的临床分析.docx
- 儿童肱骨髁上骨折后尺神经损伤恢复的预测因素分析.docx
- 康复联合舒适护理在手骨折患者中的应用及对其依从性的影响.docx
- 机器人辅助老年股骨粗隆间骨折内固定术后康复.docx
- 超声辅助定位在老年髋部骨折患者椎管内麻醉中的应用:前瞻性随机对照研究.docx
- 两岸《经济日报》全面合作拉开帷幕.docx
最近下载
- T_CAS 1148—2025(社区堆肥技术要求).pdf VIP
- 《中医诊断学》试题一.doc VIP
- 全口义齿修复中的规范化重点技术题库答案-2025年华医网继续教育.docx VIP
- 《生活垃圾填埋场环境污染隐患排查治理工作方案》(环固体〔2025〕44号).docx VIP
- 广东省广州市天河区2023-2024学年五年级上学期期末英语试卷.docx VIP
- 老年病科建设与成果汇报.pptx VIP
- 2012年10月马万成外应预测法面授录音笔记.pdf VIP
- 华南理工大学期末考试《 电力系统分析》试卷1B.doc VIP
- 妇科肿瘤综合治疗策略与预后.pptx VIP
- “铭记历史,珍爱和平”主题演讲比赛活动总结与“铸中华民族精神之魂”活动主持词合集.doc VIP
原创力文档


文档评论(0)