Search Header Logo
Lesson 1

Lesson 1

Assessment

Presentation

•

Computers

•

6th Grade

•

Practice Problem

•

Hard

Created by

raedah kalakh

Used 1+ times

FREE Resource

5 Slides • 1 Question

1

Introduction to Java Variables

By Raedah Kalakh, 20251360057

2

What is Variable?



Variables are containers for storing data values.



12

age

​A variable is like a box that holds something inside it. The thing inside can change, but the box stays the same.

Example:
📦
Box name: age
🎁
Inside the box: 12
Later, you can change what’s inside:
🎁
Now inside the box: 15

15

age

3

What is Variable Data Types?

In Java, there are different types of variables, for example:

  • String - stores text, such as "Hello". String values are surrounded by double quotes

  • int - stores integers (whole numbers), without decimals, such as 123 or -123

  • float - stores floating point numbers, with decimals, such as 19.99 or -19.99

  • char - stores single characters, such as 'a' or 'B'. Char values are surrounded by single quotes

  • boolean - stores values with two states: true or false

4

How to declare a variable

Syntax

type variableName = value;

Where type is one of Java's types (such as int or String), and variableName is the name of the variable (such as x or name). The equal sign is used to assign values to the variable.


5

How to declare a variable

Example

  • Create a variable called name of type String and assign it the value "John".

  • Then we use println() to print the name variable:

String name = "John";
System.out.println(name);



6

Fill in the Blanks

Create a variable called myNum of type int and assign it the value 15:




pattern-tertiary

Introduction to Java Variables

By Raedah Kalakh, 20251360057

Show answer

Auto Play

Slide 1 / 6

SLIDE