Key Concepts

Review core concepts you need to learn to master this subject

boolean Data Type

boolean result = true; boolean isMarried = false;

In Java, the boolean primitive data type is used to store a value, which can be either true or false.

Learn Java: Variables
Lesson 1 of 2
  1. 1
    Let’s say we need a program that connects a user with new jobs. We need the user’s name, their salary, and their employment status. All of these pieces of information are stored in our program. We…
  2. 2
    The first type of data we will store is the whole number. Whole numbers are very common in programming. You often see them used to store ages, or maximum sizes, or the number of times some code has…
  3. 3
    Whole numbers don’t accomplish what we need for every program. What if we wanted to store the price of something? We need a decimal point. What if we wanted to store the world’s population? That nu…
  4. 4
    Often our programs face questions that can only be answered with yes or no. Is the oven on? Is the light green? Did I eat breakfast? These questions are answered with a boolean, a type that ref…
  5. 5
    How do we answer questions like: What grade did you get on the test? What letter does your name start with? The char data type can hold any character, like a letter, space, or punctuation mark. …
  6. 6
    So far, we have learned primitive data types, which are the simplest types of data with no built-in behavior. Our programs will also use Strings, which are objects, instead of primitives. Objects…
  7. 7
    The Java programming language has static typing. Java programs will not compile if a variable is assigned a value of an incorrect type. This is a bug, specifically a type declaration bug. Bug…
  8. 8
    Let’s imagine we’re storing a user’s name for their profile. Which code example do you think is better? String data = “Delilah”; or String nameOfUser = “Delilah”; While both of these will comp…
  9. 9
    Creating and filling variables is a powerful concept that allows us to keep track of all kinds of data in our program. In this lesson, we learned how to create and print several different data ty…

What you'll create

Portfolio projects that showcase your new skills

Pro Logo

How you'll master it

Stress-test your knowledge with quizzes that help commit syntax to memory

Pro Logo