groovy-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Søren Martin Kristensen <>
Subject the groovy *= operator differs in behaviour from that of java
Date Mon, 27 Jun 2016 11:38:48 GMT

I have just realized that *= differs in behaviour between groovy and java.
The following source snipletsreturns 7 and 0 for groovy and java,
respectively. However, I could not find any description of this in the list
of differences between the two languages on

int a = 35;
int b = 20;
a *= b/100;
println a;

This script returns 7

public class test_multiply_operator {
  public static void main(String[] args) throws Exception {
    int a = 35;
    int b = 20;
    a *= b/100;

This java program returns 0. This is because java evaluates the right-hand
expression before multiplication.

In case I have not missed something, I guess this would be nice to have on
the list of differences between the two languages.

Best regards,

View raw message