> pls, what is syntax for methods that return void?
>
[quoted text clipped - 19 lines]
>
> Frances
If something returns void it means it doesnt actually return anything,
therefore it is a syntax error to try and assign nothing to a variable. If
you have a look at a method that returns void then you will probably see no
'return' in it, but if you do it will say 'return' and nothing else.
For your example, I would imagine setComment() takes a String as a
paramater, and the designer has decided to not return anything which makes
sense since all you are doing is passing a message in effect. Some
programmers never return void, instead they take the opportunity to at least
return a boolean for sucess/failure but this is a design choice.
Anyway, the short answer is you cannot store nothing in a variable,
therefore assigning the result of a method that returns void to a variable
doesnt work.
Allan
Frances Del Rio - 10 Jun 2005 15:00 GMT
>>pls, what is syntax for methods that return void?
>>
[quoted text clipped - 32 lines]
> therefore assigning the result of a method that returns void to a variable
> doesnt work.
ok, many thanks for yr response.. I looked at other "set" methods in
Servlet API (specif. in HttpServletResponse & ServletResponse) and well,
they all return void.. I still think this is weird.. (but Bryce is
right, of course, specif. in my ex., there IS a getComment() method, and
probaby all the others have a "get" equiv. also..) again many thanks,
also to Bryce.. Frances
>pls, what is syntax for methods that return void?
>
[quoted text clipped - 17 lines]
>
>obviously got an error here too..... thank you...
Not sure what you are asking, but void methods do not return anything,
so attempting to assign something a value from that kind of function
will not compile.
If you need to get the comment from the cookie, I'm willing to bet
there's a function getComment()..
--
now with more cowbell