0

Hi there. As I said, I'm a newbie to programming and writing code. I'm at home working on a lab project but keep getting a compilation error and I don't know how to fix it. Any help would be greatly appreciated. Here's my code:

public void add(int i)
{
int newValue;
newValue = accumulator;
accumulator = accumulator + i;
System.out.println(newValue " + " i " = " accumulator);
}

BlueJ highlights the System.out.println and displays, ')' expected error. Thank you!

Edited by happygeek: fixed formatting

2
Contributors
2
Replies
3
Views
8 Years
Discussion Span
Last Post by lovely_aly
0

You can't just put variables and strings next to one another. You need to concatenate them with the + operator: newValue + " + " + i

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.