lec04Extra

lec04Extra - String is a Java class A String object is an...

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

View Full Document Right Arrow Icon

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

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

Unformatted text preview: String is a Java class A String object is an ordered sequence of characters Positions are indexed from 0 to length()-1 String operations (from last day) length() toLowerCase() toUpperCase() charAt(int position) substring(int start) substring(int start, int last) CS125 Course Notes Lecture 4, Slide 1 indexOf(char c) returns position of the first occurrence of the character c. Example: String str = "happy! happy!"; int firstMark = str.indexOf('!'); firstMark has value 5. CS125 Course Notes Lecture 4, Slide 2 indexOf(char c, int pos) returns position of the first occurrence of the character c, starting from position pos. Example: String str = "happy! happy!"; int nextMark = str.indexOf('!',firstMark+1); nextMark has value 12. For more String operations, see text p.80-82. CS125 Course Notes Lecture 4, Slide 3 ...
View Full Document

This note was uploaded on 07/27/2009 for the course MATH 135 taught by Professor Andrewchilds during the Fall '08 term at Waterloo.

Page1 / 3

lec04Extra - String is a Java class A String object is an...

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

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