struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Cesar Arevalo <cesararev...@yahoo.com>
Subject [OT] Re: A try catch and return question
Date Mon, 01 Oct 2007 20:20:29 GMT
The blocks you mention achieve different results. In the FIRST block you will have to add a
return statement for when an exception is thrown, this allows you to set the theReturnedObject
to a value for when an exception is thrown. In the SECOND block if you are modifying theReturnedObject
in the try block then you will have to take into account that an exception might occur and
that this exception might affect the value of theReturnedObject.

Oh and by the way, this is a struts mailing list :-)

HTH
-Cesar

----- Original Message ----
From: "Zhang, Larry (L.)" <lzhang20@ford.com>
To: Struts Users Mailing List <user@struts.apache.org>
Sent: Monday, October 1, 2007 1:01:23 PM
Subject: A try catch and return question

I have a method having the following structure:

public Object myMethod() {
    try {
    // some code
    return theReturnedObject,
    }catch{
         // some code
    }
    finally {
     // some code
    }
}
 
Please let me know if the following version of code better than the
above?
public Object myMethod() {
    try {
    // some code
    
    }catch{
         // some code
    }
    finally {
     // some code
    }

    return theReturnedObject,
}

The only difference is that the bottom one put the return down to the
bottom of the method and take the return out of the try. Please let me
know.

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org





---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Mime
View raw message