bugl
bugl
HomeLearnPatternsPathsSearch
HomeLearnPatternsPathsSearch

Loading lesson path

Learn/Java/Java Tutorial
Java•Java Tutorial

Java Numbers and Strings

Flash cards

Review the key moves

1/4
Core idea

What is the main idea behind Java Numbers and Strings?

Lesson checks

Practice each idea before moving on

Short Mimo-style checks built from this lesson's code, terms, and sequence.

1Quick choice

Which statement best captures the main point of this lesson?

2Fill blank

Complete the missing token from the example code.

___ z = x + y; // z will be 30 (an integer/number)
3Order

Put the learning moves in the order that makes the concept easiest to apply.

If you add two numbers, the result will be a number:
Java uses the + operator for both addition and concatenation.
Adding Numbers and Strings

Adding Numbers and Strings

WARNING!

Java uses the + operator for both addition and concatenation.

Numbers are added. Strings are concatenated.

If you add two numbers, the result will be a number:

int x = 10;
int y = 20;
int z = x + y; // z will be 30 (an integer/number)

If you add two strings, the result will be a string concatenation:

String x = "10";
String y = "20";
String z = x + y; // z will be 1020 (a String)

If you add a number and a string, the result will be a string concatenation:

String x = "10";
int y = 20;
String z = x + y; // z will be 1020 (a String)

Previous

Java String Concatenation

Next

Java Special Characters