---
title: "+ Operator — AP Computer Science A Definition & Examples"
description: "The + operator adds numbers OR concatenates strings in Java, depending on operand types. Master left-to-right evaluation to nail AP CSA MCQ output questions."
canonical: "https://fiveable.me/ap-comp-sci-a/key-terms/operator"
type: "key-term"
subject: "AP Computer Science A"
---

# + Operator — AP Computer Science A Definition & Examples

## Definition

In AP Computer Science A, the + operator performs arithmetic addition when both operands are numeric (int or double) and string concatenation when at least one operand is a String, with expressions evaluated left to right.

## What It Is

The + operator is the one symbol in Java that does two completely different jobs. When both operands are numbers, it adds them, so `3 + 4` gives `7`. When at least one operand is a String, it concatenates, gluing the values together into a new String, so `"3" + 4` gives `"34"`. Java decides which job to do based on the types of the operands at that moment in the [expression](/ap-comp-sci-a/key-terms/expression "fv-autolink").

The part that trips people up is that Java evaluates + left to right, and the meaning can flip mid-expression. Take `"Sum: " + 2 + 3`. Java hits `"Sum: " + 2` first, sees a String, and concatenates to get `"Sum: 2"`. Then `"Sum: 2" + 3` concatenates again, producing `"Sum: 23"`. But `2 + 3 + " is the sum"` evaluates `2 + 3` first (both numbers, so real [addition](/ap-comp-sci-a/unit-1/expressions-and-assignment-statements/study-guide/01dr6uUPDAn3SjtK2Psr "fv-autolink")), giving `"5 is the sum"`. Same operator, same values, different order, different output. If you want addition inside a [concatenation](/ap-comp-sci-a/unit-1/string-methods/study-guide/SltCtk8JxBIgHcMfG6G4 "fv-autolink"), wrap it in parentheses: `"Sum: " + (2 + 3)` prints `Sum: 5`.

## Why It Matters

The + operator lives in two units at once. In [Unit 1](/ap-comp-sci-a/unit-1 "fv-autolink") ([Primitive Types](/ap-comp-sci-a/key-terms/primitive-types "fv-autolink")), it's one of the core arithmetic operators you use in expressions with int and double values, where you also have to track int vs. double results. In Unit 2 (Using Objects), it reappears as the String concatenation operator, and the CED expects you to trace mixed expressions where numbers and Strings collide. Because almost every `System.out.println()` statement on the exam mixes text labels with computed values, you can't read or write output code confidently until the dual behavior of + is automatic. It's a small operator with an outsized presence in MCQ "what is printed?" questions.

## Connections

### Arithmetic operators (Unit 1)

The + operator is one of the five arithmetic operators (+, -, *, /, %), but it's the only one that changes meaning based on type. The other four always do math, while + switches to concatenation the moment a String shows up.

### System.out.println() (Unit 1)

Print statements are where + concatenation actually gets used. Nearly every output line you write looks like `System.out.println("Count: " + count)`, so println questions are secretly + operator questions.

### [Escape Sequence (Unit 2)](/ap-comp-sci-a/key-terms/escape-sequence)

Escape sequences like \n and \" let you put special characters inside the String literals you're concatenating. [Tracing](/ap-comp-sci-a/key-terms/tracing "fv-autolink") output often means handling both at once, like a + that joins strings and a \n that splits lines.

### Comparison operators (Unit 1)

After + builds a value, comparison operators like == and < test it. The type lesson carries over too. Just as + behaves differently for Strings, == compares references for Strings, so you need .equals() instead.

## On the AP Exam

The + operator shows up constantly but almost never as a vocab question. Instead, MCQs hand you a code segment with mixed Strings and numbers and ask "what is printed?" The trap answers come from misreading left-to-right evaluation, like choosing "Sum: 5" when the code actually prints "Sum: 23". On FRQs, you'll use + yourself whenever a method needs to build and return a String, such as assembling a word, a label, or a formatted result. Two habits keep you safe: trace + one pair of operands at a time, and use parentheses when you mean arithmetic inside a concatenation.

## + Operator vs Addition vs. concatenation

These are the two faces of the same operator, and Java picks between them by type, not by what you intended. `1 + 2 + "!"` does addition first and prints "3!", while `"!" + 1 + 2` concatenates the whole way and prints "!12". If either operand in a given + is a String, that + concatenates. If both are numeric, it adds. Check types pair by pair, left to right, and the answer falls out.

## Key Takeaways

- The + operator adds when both operands are numeric and concatenates when at least one operand is a String.
- Java evaluates + left to right, so the operator's meaning can switch partway through a single expression.
- "Sum: " + 2 + 3 prints "Sum: 23" because the String makes everything after it concatenation, while "Sum: " + (2 + 3) prints "Sum: 5".
- Concatenating any primitive with a String converts that value to its String form automatically.
- Most println statements on the exam rely on + concatenation, so output-tracing questions are really testing whether you know which job + is doing.
- When in doubt, add parentheses around arithmetic inside a concatenation to force addition to happen first.

## FAQs

### What is the + operator in AP Computer Science A?

It's Java's symbol for both arithmetic addition and String concatenation. With two numeric operands it adds (3 + 4 is 7); with at least one String operand it concatenates ("3" + 4 is "34").

### Why does "1" + 1 print 11 instead of 2 in Java?

Because one operand is a String, Java converts the int 1 to "1" and concatenates, producing "11". The + operator only does math when both operands are numeric.

### Does Java evaluate + left to right?

Yes. That's why 1 + 2 + "!" prints "3!" (addition happens before the String appears) but "!" + 1 + 2 prints "!12" (the String comes first, so every + concatenates).

### How is + different from the other arithmetic operators in Java?

Subtraction, multiplication, division, and modulus only work on numbers. The + operator is the only arithmetic operator that also works on Strings, where it concatenates instead of computing. Writing "abc" - "a" is a compile-time error, but "abc" + "a" is fine.

### Can I add a number to a String variable with +?

Yes, but the result is a String, not a number. "Score: " + 95 gives the String "Score: 95". Java automatically converts the numeric value to its String form during concatenation.

## Structured Data

```json
{"@context":"https://schema.org","@graph":[{"@type":"LearningResource","@id":"https://fiveable.me/ap-comp-sci-a/key-terms/operator#resource","name":"+ Operator — AP Computer Science A Definition & Examples","url":"https://fiveable.me/ap-comp-sci-a/key-terms/operator","learningResourceType":"Concept explainer","educationalLevel":"AP® / High School","about":{"@id":"https://fiveable.me/ap-comp-sci-a/key-terms/operator#term"},"audience":{"@type":"EducationalAudience","educationalRole":"student"},"dateModified":"2026-06-11T00:50:32.313Z","isPartOf":{"@type":"Collection","name":"AP Computer Science A Key Terms","url":"https://fiveable.me/ap-comp-sci-a/key-terms"},"publisher":{"@type":"Organization","name":"Fiveable","url":"https://fiveable.me"}},{"@type":"DefinedTerm","@id":"https://fiveable.me/ap-comp-sci-a/key-terms/operator#term","name":"+ Operator","description":"In AP Computer Science A, the + operator performs arithmetic addition when both operands are numeric (int or double) and string concatenation when at least one operand is a String, with expressions evaluated left to right.","url":"https://fiveable.me/ap-comp-sci-a/key-terms/operator","inDefinedTermSet":{"@type":"DefinedTermSet","name":"AP Computer Science A Key Terms","url":"https://fiveable.me/ap-comp-sci-a/key-terms"}},{"@type":"FAQPage","mainEntity":[{"@type":"Question","name":"What is the + operator in AP Computer Science A?","acceptedAnswer":{"@type":"Answer","text":"It's Java's symbol for both arithmetic addition and String concatenation. With two numeric operands it adds (3 + 4 is 7); with at least one String operand it concatenates (\"3\" + 4 is \"34\")."}},{"@type":"Question","name":"Why does \"1\" + 1 print 11 instead of 2 in Java?","acceptedAnswer":{"@type":"Answer","text":"Because one operand is a String, Java converts the int 1 to \"1\" and concatenates, producing \"11\". The + operator only does math when both operands are numeric."}},{"@type":"Question","name":"Does Java evaluate + left to right?","acceptedAnswer":{"@type":"Answer","text":"Yes. That's why 1 + 2 + \"!\" prints \"3!\" (addition happens before the String appears) but \"!\" + 1 + 2 prints \"!12\" (the String comes first, so every + concatenates)."}},{"@type":"Question","name":"How is + different from the other arithmetic operators in Java?","acceptedAnswer":{"@type":"Answer","text":"Subtraction, multiplication, division, and modulus only work on numbers. The + operator is the only arithmetic operator that also works on Strings, where it concatenates instead of computing. Writing \"abc\" - \"a\" is a compile-time error, but \"abc\" + \"a\" is fine."}},{"@type":"Question","name":"Can I add a number to a String variable with +?","acceptedAnswer":{"@type":"Answer","text":"Yes, but the result is a String, not a number. \"Score: \" + 95 gives the String \"Score: 95\". Java automatically converts the numeric value to its String form during concatenation."}}]},{"@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"AP Computer Science A","item":"https://fiveable.me/ap-comp-sci-a"},{"@type":"ListItem","position":2,"name":"Key Terms","item":"https://fiveable.me/ap-comp-sci-a/key-terms"},{"@type":"ListItem","position":3,"name":"+ Operator"}]}]}
```
