<p>I have a variable of type Hashmap<code>&lt;String,Integer</code>>.</p>

<p>In this, the Integer value might have to go some manipulation depending upon the value of a flag variable. I did it like this...</p>

<pre><code>Hashmapvariable.put( somestring,
    if (flag_variable) {
     //manipulation code goes here
     new Integer(manipulated value);
    } else {
     new Integer(non-manipulated value);
    }
);
</code></pre>

<p>But I get an error: </p>

<blockquote>
  <p>Syntax error on token(s), misplaced
  constructs.</p>
</blockquote>

<p>at the Hashmapvariable.put call.</p>

<p>I also get another error</p>

<blockquote>
  <p>Syntax error on token ")", delete this
  token.</p>
</blockquote>

<p>at the final ");" line. But I can't delete the ")" - its the closing parentheses for the put method call.</p>

<p>I don't get this. What mistake am I doing?</p>

You cannot place a statement in the method call.
However, one option could be to make an method that returns a
```
Integer
```
such as:
```
```
private Integer getIntegerDependingOnFlag(boolean flag)
{
    if (flag)
        return new Integer(MANIPULATED_VALUE);
    else
        return new Integer(NON-MANIPULATED_VALUE);
}
```
```
Then, you can make a call like this:
```
```
hashmap.put(someString, getIntegerDependingOnFlag(flag));
```
```