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.
Format numeric values as strings - Java Tutorial
From the course: Java 8+ Essential Training: Syntax and Structure
Format numeric values as strings
- [Narrator] I've previously described how to convert a numeric value into a string, using the primitive data types helper classes, but you can also use a set of formatter classes that are provided with the Java RunTime to present formatted numbers and currency values. In this project, my main method declares a double value. Notice, I'm using the underscore characters to make the value more readable, but this is a simple primitive value of one million, two hundred thirty four thousand, and some pennies. So now, I'm going to format this. I'll use a class named Number Format. It's a member of the Java.txt package. As with all classes that aren't members of Java.lang or other automatic packages, I have to import the class. Intelligidea makes that easy, I just select the class from the list and the required import statement is added at the top. I'll call this number format, and I'll get its reference using a static method of the number format class. There are many different methods you…
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
-
-
-