Understanding Strings and Characters in Java Programming with String and StringBuffer, Slides of Applications of Computer Sciences

This chapter from 'object-oriented program development using java: a class-centered approach' covers the fundamentals of working with strings and characters in java. Topics include the string and stringbuffer classes, creating strings, constructors, string processing, string equality, conversion methods, and common programming errors. Students will learn how to manipulate strings using methods and understand when to use each class.

Typology: Slides

2012/2013

Uploaded on 04/27/2013

mehr5
mehr5 🇮🇳

4.4

(8)

36 documents

1 / 35

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Chapter 7:
Strings and Characters
Object-Oriented Program
Development Using Java: A
Class-Centered Approach
Docsity.com
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18
pf19
pf1a
pf1b
pf1c
pf1d
pf1e
pf1f
pf20
pf21
pf22
pf23

Partial preview of the text

Download Understanding Strings and Characters in Java Programming with String and StringBuffer and more Slides Applications of Computer Sciences in PDF only on Docsity!

Chapter 7:

Strings and Characters

Object-Oriented Program

Development Using Java: A

Class-Centered Approach

Objectives

  • The String Class
  • String Processing
  • The StringBuffer Class
  • Program Design and Development: Program Performance Measures and Object-Oriented Technology (OOT)
  • Common Programming Errors

Creating a String

  • Syntax:

String identifier = new String(string-value);

String identifier; identifier = new String(string-value);

String identifier = string-value;

Creating a String (continued)

  • Storage for a string is created in memory when a string is created - Location of where the string is stored is placed in a variable
  • Called a reference variable

Constructors

  • Instantiating an object is the process of using the new operator to create an object
  • The name of the constructor method must be the same name as the class
  • The String class provides nine different constructors for creating String objects

String Processing

  • Strings are manipulated using:
    • Standard String class methods
    • Character-at-a-time methods provided by the Character class

Other String Methods

  • The charAt() method permits you to retrieve individual characters in a string
  • The last position is always one less than the number of characters in the string

The StringBuffer Class

(continued)

  • String class
    • Preferred class for displaying or comparing strings that tend to remain constant
  • StringBuffer class
    • Should be used for applications that require:
      • Individual character additions
      • Modifications
      • Multiple text edits