This preview has intentionally blurred sections. Sign up to view the full version.View Full 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.
- Fall '08