OCUP UML fundamental and ITIL foundation
Jan Cumps wrote:What happens if you put the return statement after System.out in your add()?
SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6 - OCEJPAD 6
How To Ask Questions How To Answer Questions
Rob Prime wrote:The first one is what I expected, the second one is surprising as well. The compiler probably sees code without a following return statement, but it would be unnecessary.
kevinn lee wrote:Why doesnt the compiler find an error in the line 7(line I have marked as 7) when there is an error in the method add ?
David Newton wrote:
kevinn lee wrote:Why doesnt the compiler find an error in the line 7(line I have marked as 7) when there is an error in the method add ?
Because there's no error on line 7.
Dinah
The code is doing neither. It prints a string of text, and returns 0. No calculations at all.Dinah Gans wrote:Are you trying to add or multiply? Because in your method add() you are multiplying. It looks like from your comments & method name you want to be adding?
OCUP UML fundamental and ITIL foundation
Jan Cumps wrote:The code is doing neither. It prints a string of text, and returns 0. No calculations at all.
Dinah
OCUP UML fundamental and ITIL foundation
You can do anything, but not everything
You can do anything, but not everything
You can do anything, but not everything
kevinn lee wrote:But what I cant understand is why I get error "missing return statement" while there is a return statement
You can do anything, but not everything
salvin francis wrote:Hi ahamed irshad,
The OP does know whats causing the unreachable statement error,
The OP is confused about the missing return statement error:
kevinn lee wrote:But what I cant understand is why I get error "missing return statement" while there is a return statement
Switching from electric heat to a rocket mass heater reduces your carbon footprint as much as parking 7 cars. Tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
|