0

give a method a type

hey, i didnt understand how you can give a method a type.... for example: int div(){ } does the int says whats the returned var or what?

18th Oct 2016, 8:23 PM
Baran
Baran - avatar
3 Answers
+ 1
it's simple. Ex:I want to return the sum of two numbers type double, I would do... double sum = double returnSum(2.3, 3.7); The method: double returnSum(double a, double b){return a + b}
18th Oct 2016, 10:33 PM
Wanderlei Borges
Wanderlei Borges - avatar
+ 1
thx
19th Oct 2016, 11:11 AM
Baran
Baran - avatar
0
Correct: double sum = returnSum(2.3, 3.7);
19th Oct 2016, 11:27 AM
Wanderlei Borges
Wanderlei Borges - avatar