From the course: Nail Your Java Interview
Unlock the full course today
Join today to access over 22,600 courses taught by industry experts or purchase this course individually.
Normalize string input - Java Tutorial
From the course: Nail Your Java Interview
Normalize string input
- [Narrator] When developing a solution to a technical interview question, you'll often need to normalize the user's input or the data you're working with. This could mean taking out white space, making sure all the characters are lowercase or alphabetical, or more. As a part of the string data type we get a few methods for free. But you have to know what they are in order to use them in an interview. Let's take a look. In this code we have a few string variables. We've put these in a list, so they're easier to work with. Just looking at these strings, the first thing I really want to do is trim off the white space at the front and the back. Using the list, we can create a stream to access each string individually and print out the trimmed response. We'll write animals.stream.fourEach to access each individual string. We'll run a .trim on it and we'll print out that result to the console, taking away those…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
-
Concatenate strings with different methods3m 20s
-
(Locked)
Normalize string input4m 13s
-
(Locked)
Access data from strings4m 44s
-
(Locked)
Apply string functions in technical interviews4m 35s
-
(Locked)
Understand string equality4m 2s
-
(Locked)
Solution: Developing a Palindrome Checker3m 49s
-
(Locked)
Solution: Counting with String Manipulation2m 40s
-
-
-
-
-