DOC PREVIEW
LETU COSC 2103 - Chapter 11 – Strings and Characters

This preview shows page 1-2-3-4-5-6-45-46-47-48-49-50-51-92-93-94-95-96-97 out of 97 pages.

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 97 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 97 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 97 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 97 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 97 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 97 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 97 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 97 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 97 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 97 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 97 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 97 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 97 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 97 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 97 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 97 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 97 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 97 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 97 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 97 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

Chapter 11 – Strings and CharactersSlide 211.1 Introduction11.2 Fundamentals of Characters and Strings11.3.1 String ConstructorsStringConstructors.java Line 17 Line 18 Line 19 Line 20 Line 21 Line 22StringConstructors.java11.3.2 String Methods length, charAt and getCharsStringMiscellaneous.java Line 16 Line 21StringMiscellaneous.java Line 2511.3.3 Comparing StringsStringCompare.java Line 18 Line 24StringCompare.java Line 30 Lines 36-40 Line 43 and 49StringCompare.javaStringStartEnd.java Line 15 Line 24StringStartEnd.java Line 3311.3.4 Locating Characters and Substrings in StringsStringIndexMethods.java Lines 12-16 Lines 19-26StringIndexMethods.java Lines 29-46StringIndexMethods.java11.3.5 Extracting Substrings from StringsSubString.java Line 13 Line 1611.3.6 Concatenating StringsStringConcatenation.java Line 14 Line 1511.3.7 Miscellaneous String MethodsStringMiscellaneous2.java Line 17 Line 20 Line 21 Line 24StringMiscellaneous2.java Line 2711.3.8 String Method valueOfStringValueOf.java Lines 20-26StringValueOf.java11.4 Class StringBuffer11.4.1 StringBuffer ConstructorsStringBufferConstructors.java Line 9 Line 10 Line 11 Lines 13-1511.4.2 StringBuffer Methods length, capacity, setLength and ensureCapacityStringBufferCapLen.java Line 12 Line 12 Line 14 Line 17StringBufferCapLen.java Only 10 characters from StringBuffer are printed11.4.3 StringBuffer Methods charAt, setCharAt, getChars and reverseStringBufferChars.java Lines 12-13 Line 16 Lines 22-23StringBufferChars.java Lines 2611.4.4 StringBuffer append MethodsStringBufferAppend.java Line 21 Line 23 Line 25 Line 27StringBufferAppend.java Line 29-3911.4.5 StringBuffer Insertion and Deletion MethodsStringBufferInsert.java Lines 20-26StringBufferInsert.java Lines 27-38 Line 42 Line 43StringBufferInsert.java11.5 Class CharacterStaticCharMethods.javaSlide 49StaticCharMethods.java Line 54 Line 56 Line 58 Line 59 Line 60 Lines 61-62Slide 51StaticCharMethods2.javaStaticCharMethods2.java Line 44StaticCharMethods2.java Line 64Slide 55OtherCharMethods.java Lines 12-1511.6 Class StringTokenizerTokenTest.java Line 24TokenTest.java Line 33 Line 36 Lines 38-39TokenTest.java11.7 Card Shuffling and Dealing SimulationDeckOfCards.java Lines 19 and 29 Line 30DeckOfCards.java Lines 27-29 Line 43 Line 46DeckOfCards.java Line 70DeckOfCards.java Lines 92-102DeckOfCards.java Lines 108-116 Lines 114 and 123DeckOfCards.java Lines 130-13111.8 Regular Expressions, Class Pattern and Class MatcherSlide 69Slide 70ValidateFrame.javaSlide 72Slide 73Slide 74ValidateFrame.java Lines 109-118ValidateFrame.java Lines 122-137Slide 77RegexSubstitution.java Line 15 Line 20 Line 26RegexSubstitution.java Line 32 Line 38RegexSubstitution.javaRegexMatches.java Lines 13-14 Line 22 Line 24 Line 25RegexMatches.java11.9 (Optional Case Study) Thinking About Objects: Event HandlingSlide 84ElevatorSimulationEvent.java Line 8 Line 11 Line 14ElevatorSimulationEvent.javaSlide 87Fig. 11.26 Class diagram that models the generalization between ElevatorSimulationEvent and its subclasses.Fig. 11.27 Triggering actions of the ElevatorSimulationEvent subclass eventsSlide 90Slide 91Fig. 11.28 Modified collaboration diagram for passengers entering and exiting the Elevator on the first FloorSlide 93ElevatorMoveEvent.javaElevatorMoveListener.javaSlide 96Fig. 11.31 Class diagram of our simulator (including event handling) 2003 Prentice Hall, Inc. All rights reserved.Chapter 11 – Strings and CharactersOutline 11.1 Introduction11.2 Fundamentals of Characters and Strings11.3 Class String11.3.1 String Constructors11.3.2 String Methods length, charAt and getChars11.3.3 Comparing Strings11.3.4 Locating Characters and Substrings in Strings11.3.5 Extracting Substrings from Strings11.3.6 Concatenating Strings11.3.7 Miscellaneous String Methods11.3.8 String Method valueOf11.4 Class StringBuffer11.4.1 StringBuffer Constructors11.4.2 StringBuffer Methods length, capacity, setLength and ensureCapacity 11.4.3 StringBuffer Methods charAt, setCharAt, getChars and reverse 2003 Prentice Hall, Inc. All rights reserved.Chapter 11 – Strings and Characters11.4.4 StringBuffer append Methods11.4.5 StringBuffer Insertion and Deletion Methods11.5 Class Character11.6 Class StringTokenizer11.7 Card Shuffling and Dealing Simulation11.8 Regular Expressions, Class Pattern and Class Matcher11.9 (Optional Case Study) Thinking About Objects: Event Handling 2003 Prentice Hall, Inc. All rights reserved.11.1 Introduction•String and character processing–Class java.lang.String–Class java.lang.StringBuffer–Class java.lang.Character–Class java.util.StringTokenizer 2003 Prentice Hall, Inc. All rights reserved.11.2 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 2003 Prentice Hall, Inc. All rights reserved.11.3.1 String Constructors•Class String–Provides nine constructors 2003 Prentice Hall, Inc.All rights reserved.OutlineStringConstructors.javaLine 17Line 18Line 19Line 20Line 21 Line 22 1 // Fig. 11.1: StringConstructors.java2 // String class constructors.3 import javax.swing.*;4 5 public class StringConstructors {6 7 public static void main( String args[] )8 {9 char charArray[] = { 'b', 'i', 'r', 't', 'h', ' ', 'd', 'a', 'y' };10 byte byteArray[] = { ( byte ) 'n', ( byte ) 'e', 11 ( byte ) 'w', ( byte ) ' ', ( byte ) 'y', 12 ( byte ) 'e', ( byte ) 'a', ( byte ) 'r' };13 14 String s = new String( "hello" );15 16 // use String constructors 17 String s1 = new String(); 18 String s2 = new String( s ); 19 String s3 = new String( charArray ); 20 String s4 = new String( charArray, 6, 3 );21 String s5 = new String( byteArray, 4, 4 );22 String s6 = new String( byteArray ); Constructor copies byte-array subsetConstructor copies byte arrayConstructor copies character-array subsetConstructor copies character arrayConstructor copies StringString default constructor instantiates empty string 2003 Prentice Hall, Inc.All rights reserved.OutlineStringConstructors.java23 24 // append Strings to output25 String output = "s1 = " + s1 + "\ns2 = " + s2 + "\ns3 = " + s3 + 26 "\ns4 = " + s4 +


View Full Document

LETU COSC 2103 - Chapter 11 – Strings and Characters

Documents in this Course
Arrays

Arrays

16 pages

Templates

Templates

17 pages

Methods

Methods

22 pages

Methods

Methods

22 pages

Arrays

Arrays

11 pages

Load more
Download Chapter 11 – Strings and Characters
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Chapter 11 – Strings and Characters and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Chapter 11 – Strings and Characters 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?