/ Published in: Java
The first thing to notice is that this is an extremely convoluted way of multiplying two integers. Assuming the code can be compiled using Java 5 the integers can be multiplied as below. If previous jdks versions are used then autoboxing is not available and we have to convert it into a primitive and back into an Integer, but the code will still be cleaner.
The code will fail if y is a negative value, boundary checks. There are other code style issues in the code: the code is hard to read, the y variable is modified when calling multiply, and the ternary operator doesn't help to make the code clearer.
The code will fail if y is a negative value, boundary checks. There are other code style issues in the code: the code is hard to read, the y variable is modified when calling multiply, and the ternary operator doesn't help to make the code clearer.
Expand |
Embed | Plain Text