What happens when you don't return anything? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

What happens when you don't return anything?

6th Jul 2016, 12:44 PM
Stanley
4 Answers
+ 1
you use void when you don't expect any value to be returned from that method. for example int height = calculateHeight (); then you expect the method will return integer value. But if you want your method only to do something then you can use void
10th Jul 2016, 9:45 AM
Harry Marwanto
Harry Marwanto - avatar
0
it returns the garbage value.
7th Jul 2016, 6:14 PM
sunny arya
sunny arya - avatar
0
if d return type is void.. den itz k.. else u jst need to type return.. so dat the cursor gets back to where it is called. ..
7th Jul 2016, 7:45 PM
shreyansh sethia
shreyansh sethia - avatar
0
we can use void so that there is no need of return to be used....but once you r using int we need to return the value otherwise garbage value
9th Jul 2016, 8:32 PM
Jithin K C
Jithin K C - avatar