What is the difference of non void and void function?

1 answer

Answer

1043596

2026-08-16 12:10

+ Follow

If a method call is void, that means it will not return a data value to a program that calls it. Otherwise, the method is expected to return a data value of some sort.

For example, if I have a method called print() that is void, and the body of the method has a command to print a Word to the screen, the method will run that command and end.

However, if I have a method called add(int x, int y) that takes two numbers and adds them together, the program calling this method wants an answer back. So this method is not void.

ReportLike(0ShareFavorite

Copyright © 2026 eLLeNow.com All Rights Reserved.