tailieunhanh - Lecture Java methods: Object-oriented programming and data structures (2nd AP edition): Chapter 10 - Maria Litvin, Gary Litvin

Chapter 10 - Strings. In this chapter, the learning objectives are: Learn about literal strings, learn about string constructors and commonly used methods, understand immutability of strings, learn to format numbers into strings and extract numbers from strings, learn several useful methods of the Character class, learn about the StringBuffer class. | Strings "Chapter 10" Copyright © 2011 by Maria Litvin, Gary Litvin, and Skylight Publishing. All rights reserved. Java Methods Object-Oriented Programming and Data Structures Maria Litvin ● Gary Litvin 2nd AP edition with GridWorld 10- Processing text is what computers do much of the time. Your Java compiler is one example of a program that does a lot of handling and parsing of strings. Handling strings is pretty straightforward and convenient in Java. Objectives: Learn about literal strings Learn about String constructors and commonly used methods Understand immutability of strings Learn to format numbers into strings and extract numbers from strings Learn several useful methods of the Character class Learn about the StringBuffer class 10- There is no need to import because the package is imported automatically into all classes. Like the char type, String objects internally represent characters using Unicode. The + and += operators for strings are | Strings "Chapter 10" Copyright © 2011 by Maria Litvin, Gary Litvin, and Skylight Publishing. All rights reserved. Java Methods Object-Oriented Programming and Data Structures Maria Litvin ● Gary Litvin 2nd AP edition with GridWorld 10- Processing text is what computers do much of the time. Your Java compiler is one example of a program that does a lot of handling and parsing of strings. Handling strings is pretty straightforward and convenient in Java. Objectives: Learn about literal strings Learn about String constructors and commonly used methods Understand immutability of strings Learn to format numbers into strings and extract numbers from strings Learn several useful methods of the Character class Learn about the StringBuffer class 10- There is no need to import because the package is imported automatically into all classes. Like the char type, String objects internally represent characters using Unicode. The + and += operators for strings are an exception in Java, the only example of operators that work with objects. The String class An object of the String class represents a string of characters. The String class belongs to the package, which is built into Java. Like other classes, String has constructors and methods. Unlike other classes, String has two operators, + and += (used for concatenation). 10- There is no need to import because the package is imported automatically into all classes. Like the char type, String objects internally represent characters using Unicode. The + and += operators for strings are an exception in Java, the only example of operators that work with objects. Literal Strings Literal strings are anonymous constant objects of the String class that are defined as text in double quotes. Literal strings don’t have to be constructed: they are “just there.” 10- This is one of the reasons why String constructors are not used very often: instead of .