Chapter 7 Strings Prerequisites for Part II hapter5 Arrays Chapter 6 Objects and Classes You can cover GUI after Chapter 8 Chapter 8 Inheritance and Polymorphism >Chapter 11 Getting Started with GUI Programming hapter 9 Abstract Classes and Interfaces Chapter 12 Event-Driven Programming ter 10 Object-Oriented Modeling Some people hear their own inner voices with great clearness, they live by what they hear... Chapter 15 Exceptions and Assertions You can cover Exceptions and vO after Chapter 8 hapter 16 Simple Input and Output Introduction to Java Programming, revised by Dai-kaiyu
Liang,Introduction to Java Programming,revised by Dai-kaiyu 1 Chapter 7 Strings Prerequisites for Part II Chapter 6 Objects and Classes Chapter 7 Strings Chapter 8 Inheritance and Polymorphism Chapter 5 Arrays Chapter 9 Abstract Classes and Interfaces Chapter 10 Object-Oriented Modeling Chapter 11 Getting Started with GUI Programming Chapter 12 Event-Driven Programming Chapter 15 Exceptions and Assertions Chapter 16 Simple Input and Output You can cover Exceptions and I/O after Chapter 8 You can cover GUI after Chapter 8 Some people hear their own inner voices with great clearness, they live by what they hear…
Objectives o To use the String class to process fixed strings(8.2) o To use the Character class to process a single character(87. 3) o To use the String Buffer class to process flexible strings($ 7.4) To use the String Tokenizer class to extract tokens from a string (§7.5) o To know the differences among the String, String Buffer, and String Tokenizer classes(8.2-7.5) o To use the JDK 1. 5 Scanner class for console input and scan tokens using words as delimiters(87.6) To input primitive values and strings from the keyboard using the Scanner class(§7.7) o To learn how to pass strings to the main method from the command line(§78) Introduction to Java Programming, revised by Dai-kaiyu
Liang,Introduction to Java Programming,revised by Dai-kaiyu 2 Objectives ⚫ To use the String class to process fixed strings (§7.2). ⚫ To use the Character class to process a single character (§7.3). ⚫ To use the StringBuffer class to process flexible strings (§7.4). ⚫ To use the StringTokenizer class to extract tokens from a string (§7.5). ⚫ To know the differences among the String, StringBuffer, and StringTokenizer classes (§7.2-7.5). ⚫ To use the JDK 1.5 Scanner class for console input and scan tokens using words as delimiters (§7.6). ⚫ To input primitive values and strings from the keyboard using the Scanner class (§7.7). ⚫ To learn how to pass strings to the main method from the command line (§7.8)
Introduction o String and character processing O Class java. lang String O Class java. lang String Buffer O Class java. lang Character O Class java util. String Tokenizer Introduction to Java Programming, revised by Dai-kaiyu
Liang,Introduction to Java Programming,revised by Dai-kaiyu 3 Introduction ⚫String and character processing Class java.lang.String Class java.lang.StringBuffer Class java.lang.Character Class java.util.StringTokenizer
Fundamentals of Characters and strings &3 ● Characters bUilding blocks of Java source programs ●Stng O Series of characters treated as single unit O May include letters, digits, etc OObject of class string Introduction to Java Programming, revised by Dai-kaiyu
Liang,Introduction to Java Programming,revised by Dai-kaiyu 4 Fundamentals of Characters and Strings ⚫Characters “Building blocks” of Java source programs ⚫String Series of characters treated as single unit May include letters, digits, etc. Object of class String
The String Class o Constructing a String o String message =Welcome to java O String message new String( "Welcome to Java) O String S= new String o Obtaining String length and Retrieving Individual Characters in a string String o String Concatenation(concat) Substrings(substring(index), substring(start, end)) o 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 Liang, Introduction to Java Programming, revised by Dai-kaiyu
Liang,Introduction to Java Programming,revised by Dai-kaiyu 5 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