From the course: Java 8+ Essential Training: Syntax and Structure
Unlock the full course today
Join today to access over 22,600 courses taught by industry experts or purchase this course individually.
Parse String values - Java Tutorial
From the course: Java 8+ Essential Training: Syntax and Structure
Parse String values
- [Instructor] Java String class includes many methods that you can use to parse information and find sub strings. Also, the wrapper classes for the primitive values have methods that you can use to parse strings and convert them to numeric and other primitive types. For this exercise I'm working in jshell> and I'll start by declaring a string that I'll name s1, and I'll give it a value of "Welcome to California". Next, I'll evaluate the length of that string. I'll create an integer variable that I'll call 'len', and I'll get that value from s1.length. Length is a method of this string class, so you need the opening and closing parentheses at the end. And I get back a value of 22. There are 22 characters in that string. Now, let's say I wanted to find a particular sub string within the string. I want to get the position where the string begins. I'll create another variable that I'll name 'pos' for position. And I'll get it's value from s1.indexOf, and I'll pass in California. And I…
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
-
-
-
-
-
-
Declare and initialize String objects3m 45s
-
(Locked)
Create and concatenate String values4m 34s
-
(Locked)
Convert primitive values to strings5m 30s
-
(Locked)
Build a String from multiple values10m 35s
-
(Locked)
Compare String values with methods5m 19s
-
(Locked)
Format numeric values as strings7m 2s
-
(Locked)
Parse String values4m 10s
-
(Locked)
Challenge: A simple calculator56s
-
(Locked)
Solution: A simple calculator1m 26s
-
-
-