Re: Error *cannot return a value from method whose result type is void*

From: FISH (joeking_at_merseymail.com)
Date: 07/28/04


Date: 28 Jul 2004 05:05:25 -0700

xbrain21@yahoo.com (Charles) wrote in message news:<69696690.0407271045.a86440d@posting.google.com>...
> I am creating a program, but keep receiving the same error what I am
> trying to do is have it output a calendar. I have it where it outputs
> the month name and year inputted, and the days of the week. I can not
> however get it to return a value. It says "cannot return a value from
> method whose result type is void". If I change it to anything else I
> get the error "missing return statement". I have already been to:

Sometimes one error will mask anothers. I remember a couple of years
ago one Java novice posted his code to a web forum complaining that
he was getting one single compilation error on the first line. When
it was pointed out to him that the line contained a syntax error, he
retorted that he knew it did, but when he'd corrected the syntax the
compiler had given him over a hundred errors in the following code!
(True story!!)

Obviously if the method returns a value, it must say so in its defin-
ition. The true error is the "missing return statement". Take a close
look at the code in your method, and you'll see there is a route through
the code which allows the end of the method to be reached, and no return
value specified. Java is very strict on these things - a method either
always or never returns something - there isn't a 'sometimes' option. So
you need to ammend the code so all routes out will end in a valid return
statement.

-FISH- ><>



Relevant Pages

  • Re: CSWS v2.0 & CSWS_PHP v1.2 - "php4_module" error
    ... In a previous article, "Rick Barry" wrote: ... ->(The best route to ensure that a problem is addresses is to report it ... Syntax error on line 5 of /apache$root/conf/mod_php.conf: ... Can't locate API module structure `php4_module' in file /apache$root/000000/mo ...
    (comp.os.vms)
  • Re: Enter MULTIPLE Items in a Query (e.g. [Name:] ??
    ... ....then editing for my specfics gets a syntax error. ... My actual situation concerns Route numbers (I used the Name example to try to ...
    (microsoft.public.access.queries)