Yes void is OK for a method return type. Use it when the method does not return anything.
Do you get any error messages when you compile the code?
The names of your methods are misleading. A method beginning with get should return a value and not be void.
Before you write the code and give the method a name you should decide what the method is supposed to do. For example: Return a value or print a message.
What are your methods supposed to do? When you answer that then you can write the code.
NormR1
Posting Expert
6,677 posts since Jun 2010
Reputation Points: 1,138
Solved Threads: 656
Methods named get... usually return a value. Yours don't return a value so their names are misleading.
Having a method change a class level variable can lead to hidden bugs. Better to return the value and have the caller change the variable with the returned value.
What do you do with the value returned by the format method?
NormR1
Posting Expert
6,677 posts since Jun 2010
Reputation Points: 1,138
Solved Threads: 656
df.format(today);
Here is the call to the format method on line 21.
The return value is NOT received and saved.
NormR1
Posting Expert
6,677 posts since Jun 2010
Reputation Points: 1,138
Solved Threads: 656
You call a method but do NOT use the value it returns. Why bother calling the method if you ignore what it returns?
Why do you call format in this statement?
df.format(today);
Print the value of today before you call it and again after you call it to see if today is changed.
NormR1
Posting Expert
6,677 posts since Jun 2010
Reputation Points: 1,138
Solved Threads: 656