Introducing Numerical Data Types
Discovering Boolean and Char Data Types

Now, let's move on to the boolean and char data types.

The boolean data type in Java can hold one of two possible values: true or false. This data type is widely used in logical expressions and decision-making. Here's a simple example:

Java
boolean isEarthRound = true;
System.out.println(isEarthRound);  // This will print: true

boolean isEarthFlat = false;
System.out.println(isEarthFlat); // This will print: false

The char data type is used to store a single character. Java uses Unicode, allowing a char to store any character! Here's how it's done:

char firstLetterOfAlphabet = 'A'; // A character is always surrounded by single quotes
System.out.println(firstLetterOfAlphabet); // This will print: A
Exploring String Data Type

You'll find that String is as common in Java as stars in the cosmos. Java treats String as a basic data type and uses it to store a sequence of characters - just a text. The string is always surrounded by double quotes.

String welcome = "Welcome to Java!";
System.out.println(welcome); // This will print: Welcome to Java!

What's interesting to note is the immutability of String in Java. Once a String is created, its value can't be changed.

Sign up
Join the 1M+ learners on CodeSignal
Be a part of our community of 1M+ users who develop and demonstrate their skills on CodeSignal