Can a void method have a return statement?
Though void means that it does not return a value…. if we are defining our function as void that means we dont want it to return values to us. But in some cases, we can have an if loop inside the function which checks whether it is valid to continue or not, in that case if it is invalid then we can write the statement return without any values… this will make the function go to the end of the method and return as a failure. As it is not returning any value we do not need to write the function as an int. public void check() { if(argv < 2) { return; } ..... normal functioning ..... .. } this checks for the command line argument, if the no of arguments are less than 2, there can not be any functioning, in this case program needs to be terminated....