What do void methods return?

Viewed 57

Here's Stack Overflow's own definition of a void:

Void :

An incomplete type used as syntactic place-holder for the return type of a method/function when no value is returned.

So, what does it return?

I know this may seem like a strange question since voids aren't supposed to return anything.

But I still wonder:

  • Do they return null?
  • Do they return undefined?
  • Does it just throw an exception?
  • Does it have a specific return value, and/or a specific system for these cases?

Or, probably, the question I should've asked first:

  • Does it change according to the language we're using? / Does it depend on the language we're using? (I'm using Java for this one)

So, what happens if I do System.out.println(function());, considering that function() is a void?

0 Answers
Related