+ 1

I don't understand the "void" function and why a method should have it or why not have it?

17th May 2015, 9:34 PM
7 Answers
+ 6
there are 2 types of method : void return you cannot make a method without any of these types
29th Oct 2015, 9:17 AM
a l l y z a
a l l y z a - avatar
+ 5
void means your method does not return any values. If your method does not have void, it must return something (int, String, double, etc.)
14th Feb 2016, 3:14 PM
Vishnu Madhusoodanan
Vishnu Madhusoodanan - avatar
+ 4
When a method you defined does not have the "return" keyword, you use "void". However, if it does have the "return" keyword, you use the data type for the return value. For integers, you use int For strings, you use string . . . In summary, "void" means nothing is returned.
17th Nov 2016, 10:14 AM
Toheeb - avatar
+ 3
void is basically used for not returning any data type such as int,float or others but a data type method such as int number() can only return intiger but void can't return anything can only stream and modify values
7th Jun 2020, 9:10 AM
Gorom_Pani - avatar
+ 1
We create functions. Some of them doesn't returns any value then how can we take it's return type. Here we need something which can restrict the use of return in my function, So 'void' is used when a function doesn't return anything.
18th Nov 2016, 6:38 AM
Jai Verma
Jai Verma - avatar
+ 1
void doesnot return anything.
7th Apr 2017, 5:45 PM
Aditya Gupta
Aditya Gupta - avatar
void means empty or zero. so we use it in methods in which values don't need to be returned
3rd Dec 2016, 5:39 PM
Gayatri Chatterjee
Gayatri Chatterjee - avatar