+ 2

What does ___sum ((int)a, (int) b)___do exactly? (line 5)

public class Program{ public static void main (String []args){ double a = 3.14; double b = 5.56; sum((int)a,(int)b);} static void sum (int a,int b) { System .out .println (a+b); } }

13th Jul 2017, 11:24 PM
reza
reza - avatar
3 Respostas
+ 3
the (int) convert double data type to integer data type...... so 3.14 and 5.56 get converted into 3 and 5 respectively... then these integers i.e. 3 and 5 are used as parameters when calling the sum function.......
14th Jul 2017, 12:06 AM
cHiRaG GhOsH
cHiRaG GhOsH - avatar
+ 2
It will add those two perimeters together, sum(a, b) is the same like a+b
14th Jul 2017, 12:09 AM
Aleksandar Stevanovic
Aleksandar Stevanovic - avatar
+ 1
It calls the sum functions with the parameters (int)a (==3) and (int)b (==5)
13th Jul 2017, 11:52 PM
Baptiste E. Prunier
Baptiste E. Prunier - avatar