when u write void before methods it means it returns nothing.fine.but sum method returns the value of the sum .when u add 2 numbers it returns a new number.then how can we write void before sum method? m confused.i know i lack clarity.so please clear it.Thanks folks in advance.
anupam jha
Level 7
void...
Under discussion
Comments (3)
- Popular
- New
- Old
You must be signed in to leave a comment
remote87
2 January 2021, 04:57
If you need to use a value as a result from a method you need a return value ( primitive data type, object or whatever ), if you just need to see a result from a calculation or something like that ( print on the screen or sum some numbers ) you do it with a void and you don't use the result of the method...if I understand it corectly.
0
anupam jha
2 January 2021, 07:33
thats fine.Thanks.Hope u r right .if you are nt going to use the result value then u can write void? cool.
0
Nouser
1 January 2021, 17:29
Please post the code you're having questions about.
0