Left Hand Side Of An Assignment Must Be A Variable Way

I am working on editing a Jasper report. When I assign a double value to a variable which is of type double, I am getting the following error during compilation:

The left-hand side of an assignment must be a variable             (((java.lang.Double)variable_slabSum.getValue())=new Double(0.0) && (((java.lang.Double)field_percent.getValue()) + " of first " + ((java.lang.Double)field_slab_end.getValue()))

"slabSum" is a variable created of type double and I am trying to assign a value of "0" to it, when certain condition is met, in a conditional statement.
$V{slabSum}==0 ?
    ($F{percent} + " of first " + $F{slab_end}) :
            ($V{slabSum}=new Double(0.0) && ($F{percent} + " of first " + $F{slab_end})))

Any suggestions would be helpful.

Thank you


After programming in Scheme for months, going back to Java can cause some problems as you can imagine. I encountered this error a few days ago while writing just the simplest searching loop.

public static void main(String[] args) { int[] arr = new int[] {2804, 2374, 6382, 1899}; int index = 0, largest = arr[0]; for (int i = 1; i < arr.length; i++) { (if largest > arr[i]) { index = i; largest = arr[i]; } } }

It’s your typical searching for the largest value loop. It’s nothing special, but then again, it doesn’t work.

At least the error message is logical. No, not really.

the left-hand side of an assignment must be a variable

By studying very carefully and fully realizing that I am still in scheme mode, I notice that there is a parenthesis before the if-statement instead after the keyword itself. Had I been helping someone else with this code and they showed me that error message along with this, would I have known it was a misplaced parenthesis? No way. I’d eliminate one possibility at a time by removing each successive layer of expressions and assignments until it stopped. I might even go so far as to retype the entire thing. It’s subtle.

It also turns out that if you try to assign a value to a method, you’ll cause this error too.

Happy language switching!

Tagged: assignment, error, Java

0 Thoughts to “Left Hand Side Of An Assignment Must Be A Variable Way

Leave a comment

L'indirizzo email non verrà pubblicato. I campi obbligatori sono contrassegnati *