when I do this code:
public class TryingOutReturn {
public static void main (String[] args) {
float numa = 2;
float numb = 3;
System.out.println(addition(numa, numb));
}
public static int addition (float num1, float num2) {
float sum = num1 + num2;
return sum;
}
}
It gives me the
----jGRASP exec: javac -g TryingOutReturn.java
TryingOutReturn.java:10: error: incompatible types: possible lossy conversion from float to int
return sum;
^
1 error
----jGRASP wedge2: exit code for process is 1.
----jGRASP: operation complete.
Why does java have difficulty returning me a value in float? I don't understand what it means by possible lossy conversion what does lossy even mean?