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.
Work with character values - Java Tutorial
From the course: Java 8+ Essential Training: Syntax and Structure
Work with character values
- [Instructor] Java distinguishes between characters and strings. A character is a primitive data type and it consists of just a single character. A string is a complex object and can reference a complete collection of characters in a particular order. The primitive type is called char c-h-a-r and, just like any of the primitive types, it's spelled in all lowercase. I'll declare a variable of that type that I'll call c1. And I'll give it a literal value of the number one wrapped in single quotes. A literal for the character type is wrapped in single quotes while a literal for the string type is wrapped in double quotes. Now do the same thing for character two. I'll give it a value of two and then I'll create another one with the value of three. So those are three individual primitive values. There's another way of referencing a character and that's by its unicode value. To do this properly, you'll need a unicode chart. And here's one of many that are available on the web. When you're…
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)
Work with primitive variables6m 35s
-
Declare and modify primitive values4m 48s
-
(Locked)
Store currency values with BigDecimal3m 32s
-
(Locked)
Convert values between numeric types3m 19s
-
(Locked)
Math operators and the Math class3m 11s
-
(Locked)
Work with boolean values2m 51s
-
(Locked)
Work with character values4m 12s
-
(Locked)
More about Java operators4m 48s
-
(Locked)
-
-
-