I am new to java. I read here that when we're casting from an int to a double type, it happens automatically(as it's widening casting, not narrowing casting). However, when I tried it out by myself with the following code:
int a = 3;
int b = 11;
double sum = a/b; //widening casting happens automatically
...but got the answer of 0.0 instead of 0.27. I know that this is wrong since a/b will return type int(0) and then that int will become a double of 0.0. However, I'm not sure how to fix this.
Thank you so much for help!