Partition between integers in Java
•
Java
I need to divide integers in Java, and the result should be a floating point number
Can I use the / symbol? For example:
int integer1 = 1; int integer2 = 2; float quotient = integer1 / integer2; // Could I do this?
Solution
Convert one of the integers to float to ensure floating-point division:
float result = integer1 / (float) integer2
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
二维码