Lesson 8 - Activity 1 - Are there other variables you can use in Java?

Time: 15 minutes

Purpose: Explore other variables available in Java

Introduction: Youโ€™re covered int, double, String, Boolean. But there are other variables available.

Task: Investigate other variable types.

[We will mainly be using int, double, String, Boolean. But there are others!]

Look into other variables available in Java and compare them to the ones we are using.

  • byte (number, 1 byte)
  • short (number, 2 bytes)
  • int (number, 4 bytes)
  • long (number, 8 bytes)
  • float (float number, 4 bytes)
  • double (float number, 8 bytes)
  • char (a character, 2 bytes)
  • boolean (true or false, 1 byte)

Awesome - about 40 years ago, these data types were really cruicial, memory on machines was really limited so using the smallest variable we could was important for an operation. In these days you might only have a 1kb of memory for your program to work with.

Now even a basic smartphone has 4gB + of memory โ€ฆ not so much.