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.
Declaring and initializing numeric primitives - Java Tutorial
From the course: Java 8 Essential Training
Declaring and initializing numeric primitives
- You can represent numbers in Java as either primitive values or as complex objects. I'll show you how to represent them as primitives here and then show how to use helper classes to get information about numeric values. I'm working in the project PrimitiveNumbers. It has two classes named Main and MaxValues. Both of these classes have a Main method but no executable code. In the Main class, I'll add code to the Main method. And I'm going to declare six variables each using one of the primitive numeric data types. I'll start with a byte that I'll name b and assign it a value of one. Then I'll create a short integer. I'll name that sh and I'll give that a value of one as well. Then an int, a 32 bit integer. I'll name that i and give it a value of one. And then a long integer with the type long. I'll assign that the name of l and give it a value of one as well. Notice all of these integer types are using a literal of one. The compiler looks at the value of one and always starts with an…
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 primitive variables8m 4s
-
(Locked)
Declaring and initializing numeric primitives6m 14s
-
(Locked)
Representing currency values with BigDecimal5m 10s
-
(Locked)
Converting numeric values5m 37s
-
(Locked)
Using mathematical operators and the Math class6m 1s
-
(Locked)
Working with Boolean values and expressions4m 49s
-
(Locked)
Working with character values3m 23s
-
(Locked)
Using Java operators6m 11s
-
(Locked)
-
-
-
-
-
-
-
-
-