String methods: quick reference
10 min · Beginner
Need help? Ask a tutor on WhatsApp (opens in a new tab)A one-page sheet of every String method from this module, grouped by job. Each line shows a call and its result, so you can look one up in seconds while you solve problems. Bookmark this page.
What you will learn
- Find the right String method for a task quickly
- Know what each String method returns
Topics in this lesson
- Inspect and cut
- Search
- Compare
- Change: case, spaces and text
- Split, join and convert
Key points
- Indexes start at 0;
substring(a, b)stops beforeb, andindexOfgives-1when nothing is found. - Compare text with
equals()orequalsIgnoreCase(), never==. - Strings never change:
toUpperCase(),trim(),replace()and the rest return a new String, so store the result. - Text to number:
Integer.parseInt(s); number to text:String.valueOf(n).
Sign in to continue this lesson
Create an account to read every lesson, practise with the exercises and keep track of your progress.