COP 3502 Lecture Notes - Lecture 9: Substring
Document Summary
A se(cid:395)ue(cid:374)(cid:272)e of sy(cid:373)(cid:271)ols (cid:894)like (cid:272)ha(cid:396)a(cid:272)te(cid:396)s(cid:895) i(cid:374) (cid:272)o(cid:373)pute(cid:396) s(cid:272)ie(cid:374)(cid:272)e. java st(cid:396)i(cid:374)gs a(cid:396)e . Built into the language itself (no import necessary) Are immutable - o(cid:374)(cid:272)e (cid:272)(cid:396)eated, they (cid:272)a(cid:374)"t (cid:271)e (cid:272)ha(cid:374)ged. Unlike most types covered so far, (char, boolean, int, float, etc), which are primitive types (variables hold their own values), string is a reference type (variables hold a reference to the object): Instance methods can only be invoked by an instance of the class. Some instance methods provided by the string class. Returns the number of characters in this string. Returns the character at specified index from this string. Returns new string with all letters in uppercase. Returns new string with all letters in lowercase. Returns new string with whitespace characters trimmed (both sides) Returns this string"s substring from begin to the end of string. Return this strings substring from begin to end-1. Can be invoked without an instance of the class.