+ (sum) operator

The left-associative, binary infix + operator is used to sum two operands.

Usage

Integer three = 1 + 2;
String concatenated = "foo" + "bar";

Description

Definition

The + operator is defined as follows:

lhs.plus(rhs);

See the language specification for more details.

Polymorphism

The + operator is polymorphic. The meaning of + depends on the Summable interface.

Type

The result type of the + operator is the same as the type of its right hand operand.

Meaning of + for built-in types

For the built-in numeric types Integer and Float, + performs normal mathematical addition, subject to the limitations of the relevant type.

For String, + performs concatenation.

See also