```
public class Solution {
private int gcd(int x, int y){
if(y == 0)
return x;
return gcd(y, x%y);
}
public boolean canMeasureWater(int x, int y, int z) {
if(z > Math.max(x, y)) return false;
return (z % gcd(x, y)) == 0;
}
}
```