Key Concepts

Review core concepts you need to learn to master this subject

`int` Data Type

``````int num1 = 10;   // positive value
int num2 = -5;   // negative value
int num3 = 0;    // zero value
int num4 = 12.5; // not allowed``````

In Java, the `int` datatype is used to store integer values. This means that it can store all positive and negative whole numbers and zero.

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

How you'll master it

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