From the course: Java 11+ Essential Training
Unlock the full course today
Join today to access over 22,500 courses taught by industry experts or purchase this course individually.
Format numeric values as strings - Java Tutorial
From the course: Java 11+ Essential Training
Format numeric values as strings
- [Instructor] I've previously described how to convert a numeric value to a string, using the primitive data types helper or wrapper classes. But you can also use a set of formatter classes to format numbers and currency values. You start by creating instances of these classes. I'll create one that I'll call numf, and I'll get that object using this expression, NumberFormat.getNumberInstance. There are a number of different methods that return instances of various objects. Now notice, when I reference the number format class, that there's an import statement that's being generated automatically by intelliJ IDEA. I'll talk more about imports later on, but what's important to know now, is that there's a certain set of classes in Java, such as the string class and those wrapper classes, that don't have to be explicitly imported, they're always available to the compiler. All other classes have to be imported. An import…
Contents
-
-
-
-
-
-
(Locked)
Declare and initialize string values3m 55s
-
(Locked)
Build a string from multiple values4m
-
(Locked)
Clone the exercise files from GitHub3m 57s
-
(Locked)
Convert primitive values to strings3m 29s
-
(Locked)
Format numeric values as strings5m 55s
-
(Locked)
Interpolate strings with placeholders3m 7s
-
(Locked)
Compare string values4m 27s
-
(Locked)
Parse string values2m 36s
-
(Locked)
Get string values from user input3m 34s
-
(Locked)
Challenge: A simple calculator1m 9s
-
(Locked)
Solution: A simple calculator1m 18s
-
(Locked)
-
-
-
-
-
-