ch07 - Java Programming Fourth Edition Chapter 7...

Info iconThis preview shows pages 1–12. Sign up to view the full content.

View Full Document Right Arrow Icon
Java Programming Fourth Edition Chapter 7 Characters, Strings, and the StringBuffer
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Java Programming, Fourth Edition 2 Objectives • Identify problems that can occur when you manipulate string data • Manipulate characters • Declare a String object • Compare String values • Use other String methods
Background image of page 2
Java Programming, Fourth Edition 3 Objectives (continued) • Convert Strings to numbers • Learn about the StringBuffer class
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Java Programming, Fourth Edition 4 Identifying Problems that Can Occur When You Manipulate String Data • Manipulating characters and groups of characters – Provides some challenges for beginning Java programmer • String is a class – Each created String class object – String variable name not simple data type – Reference • Variable that holds memory address
Background image of page 4
Java Programming, Fourth Edition 5 Identifying Problems that Can Occur When You Manipulate String Data (continued) • Compare two Strings using == operator – Not comparing values – Comparing computer memory locations • Compare contents of memory locations more frequently than memory locations themselves
Background image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Java Programming, Fourth Edition 6 Identifying Problems that Can Occur When You Manipulate String Data (continued) • Classes to use when working with character data – Character • Instances hold single character value • Defines methods that can manipulate or inspect single-character data – String • Class for working with fixed-string data – Unchanging data composed of multiple characters
Background image of page 6
Java Programming, Fourth Edition 7 Identifying Problems that Can Occur When You Manipulate String Data (continued) • Classes to use when working with character data (continued) – StringBuffer • Class for storing and manipulating changeable data composed of multiple characters
Background image of page 7

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Java Programming, Fourth Edition 8 Manipulating Characters • Character class – Contains standard methods for testing values of characters – Methods that begin with “is” • Such as isUpperCase() • Return Boolean value • Can be used in comparison statements – Methods that begin with “to” • Such as toUpperCase() • Return character that has been converted to stated format
Background image of page 8
Java Programming, Fourth Edition 9 Commonly Used Methods of the Character Class
Background image of page 9

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Java Programming, Fourth Edition 10 The TestCharacter Application
Background image of page 10
Java Programming, Fourth Edition 11 Declaring a String Object • Literal string – Sequence of characters enclosed within double quotation marks – Unnamed object, or anonymous object of
Background image of page 11

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 12
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 02/13/2011 for the course 332 351 taught by Professor Staff during the Fall '08 term at Rutgers.

Page1 / 38

ch07 - Java Programming Fourth Edition Chapter 7...

This preview shows document pages 1 - 12. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online