From the course: Nail Your Java Interview
Unlock the full course today
Join today to access over 24,700 courses taught by industry experts.
Access data from strings - Java Tutorial
From the course: Nail Your Java Interview
Access data from strings
- [Instructor] Now that we know some ways to normalize our input. Let's talk about how we can access the data inside of our string. Much of this functionality is already built in with string instance methods. Most of these methods use indexing for accessing each character stored in the string. Looking at the first variable here, we could say that A is a index zero, P is a index one, P is a index two and so on for the rest of the string. The last index in the string is the length of the string minus one. So here for apples, since the length is six the last index must be five because we start our counting at zero. To access a character at a given index we can use the strings charAt method. Let's say we want to access the first character. All right, char first character, create a variable. We'll access the string, apples, use charAt, that built in functionality and our input will be zero. Because the first…
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
-
-
-
-
-