CSE 8B Chapter Notes - Chapter 4.4: Whitespace Character, Concatenation, Substring

20 views4 pages

Document Summary

String is a reference type: references string object. Strings are objects: their methods are called instance methods, since you need an instance of the string class to call them. Let"s say (cid:449)e ha(cid:448)e a tri(cid:374)g o(cid:271)je(cid:272)t (cid:272)alled s. To get a specific character: s. charat(index, output will be from 0 to s. length()-1. Concatenation can occur 2 ways: string1. concat(string2), string1 + string2. One of the items being concatenated must be a string for concatenation to take place: non-string items are first converted to strings, then concatenated. 4. 4. 4 converting strings tolowercase() returns new string that is all lower case touppercase() returns new string that is all upper case trim() returns new string with all whitespace eliminated. 4. 4. 5 reading a string from the console. Following code reads 3 strings from user input. Next() reads string ending with whitespace character. Nextline() reads string once enter key is presses. 4. 4. 6 reading a character from the console.

Get access

Grade+20% off
$8 USD/m$10 USD/m
Billed $96 USD annually
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
40 Verified Answers
Class+
$8 USD/m
Billed $96 USD annually
Class+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
30 Verified Answers

Related Documents

Related Questions