How to divide two numbers in Java and get to different types in two different situations:
- Get int if it is possible(for example 6 / 2)
- Otherwise, get float(6 / 4)
Code like this:
int a;
int b;
float div = a / b;
a and b are integers. (For example, I don`t want to get 2.0 if it is possible to get 2)