Ask a Question
Ask Question Login
Corporate Training
  1. Community
  2. Java
  3. Question
Java

What does java return void mean?

Asked by Jacob Rutherford Oct 6, 2022 1.6K views 1 answer
Share

About this question

Does / why does Java need to have void methods? Reference:

Any method declared void doesn't return a value.

As far as I can think, every use of void would be better served by returning a status flag, the object being invoked, or null.

This would make every call a statement that is assignable, and would facilitate builder patterns and method chaining. Methods that are only invoked for their effects would usually return a boolean or a generic Success type or throw an exception on failure.

Your answer

1 Answer

More Java discussions

Learn & Explore

Free tutorials and interview questions from industry experts — learn the skill, then get ready to prove it.

Latest Java Blogs

Guides, tips and career advice on Java from JanBask experts.