Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in Java by (6.5k points)
edited by

Could someone help me in making a JAVA Function without having to return a value?

1 Answer

0 votes
by (11.3k points)
edited by

We use void return type functions for this. These functions don't have a standard return type and are replaced with void. This means that void functions aren't called to return a value, they are called as statements. 

For instance, the following is an example of how a void function is defined:

public static void helloworld(int a){}

You can simply call this method via:

helloworld(3);

Instead of using a variable to store the return value of the function.

Related questions

0 votes
1 answer
0 votes
1 answer
asked Mar 6, 2021 in Java by Jake (7k points)
0 votes
1 answer
asked Mar 11, 2021 in Java by Jake (7k points)

31k questions

32.8k answers

501 comments

693 users

Browse Categories

...