10-string-methods

10-string-methods - Strings and Things CSE 114(Computer...

Info iconThis preview shows pages 1–5. 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

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: Strings and Things CSE 114 (Computer Science I) SUNY at Stony Brook 1 Strings Are Fundamental! • The String class is probably the most commonly used class in Java programming • Let’s take a quick look at the methods provided by the String class... Strings Are Fundamental! • The String class is probably the most commonly used class in Java programming • Let’s take a quick look at the methods provided by the String class... 2 String Methods • String() — creates a new String • ex. String s = new String(“Hello!”); • Shorthand: String s = “Hello!”; • length() — returns the total number of characters in the String • trim() — returns a new String with no leading or trailing whitespace 3 String Methods • charAt() — returns the character at a given index • Indices range from 0 to (length - 1) • indexOf( str ) — returns the Frst index at which str occurs in the string (or -1 if it isn’t there) • toLowerCase() / toUpperCase() — return a new copy...
View Full Document

This note was uploaded on 03/22/2009 for the course CSE 114 taught by Professor Tashbook during the Spring '08 term at SUNY Stony Brook.

Page1 / 8

10-string-methods - Strings and Things CSE 114(Computer...

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

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