The course is part of this learning path
This course delves into the String class and looks at the functionality it provides through a host of methods. We will also discuss how string objects are immutable, which means the object itself can't be modified once they've been created.
Learning Objectives
- Learn how the StringBuilder class differs from the string class
Intended Audience
- Beginner coders or anyone new to Java
- Experienced Java programmers who want to maintain their Java knowledge
- Developers looking to upskill for a project or career change
- College students and anyone else studying Java
Prerequisites
This is a beginner-level course and can be taken by anyone with an interest in learning about Java.
In this section, we've learned about how to work more effectively with text data primarily using the string class. We discussed some of the incredibly useful methods that the string class offers, including the equals and compare two methods for comparing strings, and how they differ from usage of the double equal sign or equal to operator, which compares the addresses when applied to reference types like string. Further, we discussed the length and charAt methods obtaining useful information about the string object we're working with.
Later, we discussed the toUpperCase and toLowerCase methods for obtaining upper and lowercase versions of a string, as well as the substring method for obtaining portions of a string and the indexOf method for finding the index of a particular character or substring within a string. After our discussion of the string class, we took a look at the StringBuilder class. We saw how the string class is immutable and that the StringBuilder is mutable.
Mutability refers to the capability of modifying or mutating, which is where the word mutable comes from, the contents of an object. In the case of the string class, you cannot modify the object once it is created. StringBuilder on the other hand allows you to modify the textual data that you are working with. We finished off the section with a project that split strings, store them in ArrayLists, and printed permutations of the first and last names. In the next section, we will discuss methods. I'll see you there.
John has a Ph.D. in Computer Science and is a professional software engineer and consultant, as well as a computer science university professor and department chair.