From the course: Java 8 Essential Training
Unlock the full course today
Join today to access over 22,600 courses taught by industry experts or purchase this course individually.
Parsing string values - Java Tutorial
From the course: Java 8 Essential Training
Parsing string values
- Java's String class includes many methods that you can use to parse information and find substrings. I'll show you some of them here in the project ParsingStrings. I've declared a string with a value of Welcome to California. And first, I'll display the length of that string. I'll use some System output and I'll start with a label of Length of string and I'll pinch to that the expression s1.length. Length is a method of the String class. I'll run that code and the result is Length of string: 22. Now, let's say that I wanted to find a particular substring within that string. You can do that with a method named indexOf. It returns an integer value, so I'll create a variable named position declared as an int and I'll get its value by calling s1.indexOf. And I'll pass in the substring I'm looking for. Then I'll output that information to the console starting with Position of substring and then outputting the position. And the result is Position of substring: 11. Now, just as with…
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
-
-
-
-
-
-
-
(Locked)
Working with object data types6m 27s
-
Using the String class5m 5s
-
(Locked)
Converting primitive values to strings4m 15s
-
(Locked)
Building a string from multiple values8m 44s
-
(Locked)
Comparing string values5m 51s
-
(Locked)
Formatting numeric values as strings4m 41s
-
(Locked)
Parsing string values3m 13s
-
(Locked)
Working with dates and times8m 35s
-
(Locked)
Challenge: Creating a simple calculator application1m 28s
-
(Locked)
Solution: Creating a simple calculator application1m 19s
-
(Locked)
-
-
-
-
-
-
-
-