Jump to content


Check out our Community Blogs

travy92

Member Since 02 Sep 2007
Offline Last Active Sep 30 2015 08:17 PM
-----

Posts I've Made

In Topic: what is void and return keywords?

30 October 2011 - 07:24 PM

A method that returns 'void' means it does not return anything.
Void methods usually change something. Ie. Mutator methods that change a variable.

And for methods that return something:
Say you wanted to get the value of a private variable of another class, you would use an accessor method to return this variable.

In short:
Methods that return void return nothing.
The rest return something. Ie. Integers, Strings etc.

In Topic: Scanner problems

14 March 2011 - 12:38 AM

Thanks for the help, this solved the problem. However I have encountered another problem. If the user presses the Return keys (enter) a few times, and then types something 5 lines down, the program will then return 5 messages saying the user has not inputted a valid number.
Eg.






~somthing invalid~

Will return:
You have not entered a valid age, please try again.
You have not entered a valid age, please try again.
You have not entered a valid age, please try again.
You have not entered a valid age, please try again.
You have not entered a valid age, please try again.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download