computer programming 2 n.
Download
Skip this Video
Loading SlideShow in 5 Seconds..
Computer Programming 2 PowerPoint Presentation
Download Presentation
Computer Programming 2

Loading in 2 Seconds...

play fullscreen
1 / 9
graham-coleman

Computer Programming 2 - PowerPoint PPT Presentation

71 Views
Download Presentation
Computer Programming 2
An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.

- - - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript

  1. MINISTRY OF EDUCATION & HIGHER EDUCATION COLLEGE OF SCIENCE AND TECHNOLOGY (CST) KHANYOUNIS- PALESTINE Computer Programming 2 Lecture 6: String Processing Part c: Class StringBuffer Prepared & Presented by: Mahmoud Rafeek Alfarra

  2. و من يتقِ الله ... ألا تكفيك هذه ؟! (إِنَّ اللَّهَ مَعَ الَّذِينَ اتَّقَوْا وَالَّذِينَ هُمْ مُحْسِنُونَ) (النحل:128) شريحـة ثابتـة لعلنا نحسن من خلالها أخلاقنـا و أفعالنا لنفوز يوم الامتحان الحقيقي Downloaded from http://staff.cst.ps/mfarra

  3. Out Lines • What is a StringBuffer class ? • Functions of StringBuffer Class: • append() • insert() • reverse() • setCharAt() • charAt() • substring() • deleteCharAt() • length() • delete() • capacity() • setLength() • ensureCapacity() • toString() Downloaded from http://staff.cst.ps/mfarra

  4. What is a StringBuffer class ? • A Stringbuffer class implements a mutable sequence of characters. • A string buffer is like a String, but can be modified. • At any point in time it contains some particular sequence of characters, but the length and content of the sequence can be changed through certain method calls. Downloaded from http://staff.cst.ps/mfarra

  5. Functions of StringBuffer Class • append(): is used for the concatenate the string in string buffer. • This is better to use for dynamic string concatenation. • This function works like a simple string concatenation such as : String str = str + "added string";. Downloaded from http://staff.cst.ps/mfarra

  6. String in Java • insert() • This is the insert() function used to insert any string or character at the specified position in the given string. StringBuffer buffer = new StringBuffer(“MFarra”); buffer.insert( 1, “R” ); Downloaded from http://staff.cst.ps/mfarra

  7. Class String • reverse(): used to reverse the string present in string buffer. • setLength(int newLength)Sets the length of this String buffer. • capacity()Returns the current capacity of the String buffer. Downloaded from http://staff.cst.ps/mfarra

  8. Case Study Return to chapter 29, and understand the remainder of functions Downloaded from http://staff.cst.ps/mfarra

  9. Next Lecture … Class Regular Expressions Downloaded from http://staff.cst.ps/mfarra