File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Beginning Java and the fly likes Unreachable code question Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Unreachable code question" Watch "Unreachable code question" New topic

Unreachable code question

Melinda Savoy
Ranch Hand

Joined: Jun 21, 2005
Posts: 387

In the following code, where BOLDED, I do not understand why this is UNREACHABLE CODE:

public class EndTransactionSOAPImpl implements org.tempuri.EndTransaction_PortType{
public org.texashealth.www.SCM.DataTier.GenericResponse.GenericResponse
endTransaction(org.texashealth.www.SCM.DataTier.ETRequest.EndTransactionRequest endTransaction
) throws java.rmi.RemoteException {

// Create the "GenericResponse" and "Header" objects.
GenericResponse response = new GenericResponse();
Header responseheader = new Header();

// Stuff the responseheader with the hardcoded VERSION and STATUS.

// Stuff the "response" object variable by passing
// in the header object.

// Delete or keep the transaction by verifying the transaction exists in the hash table.
Transaction transaction = new Transaction();
if (endTransaction.getHeader().getVersion().intValue() != 1)
return response;

int transID = endTransaction.getTransactionID().intValue();
if (Transaction.get(transID) == null)
return response;

return response;

Any help or direction would be appreciated.

Paul Sturrock

Joined: Apr 14, 2004
Posts: 10336

That's what's stopping you. Its always a good idea to use curly brackets {} to demarcate blocks of logic, such as if conditions. Without the brackets, your if() only includes the one line after it in its conditional block.
[ July 08, 2005: Message edited by: Paul Sturrock ]

JavaRanch FAQ HowToAskQuestionsOnJavaRanch
Shrinivas Mujumdar
Ranch Hand

Joined: Aug 27, 2004
Posts: 328
See the line above bold variable you are saying return statement so how you can expect the control will go to the next line. The if statement you have written must have a {}block after that & return should be inside that block.

Melinda Savoy
Ranch Hand

Joined: Jun 21, 2005
Posts: 387

The braces {} were indeed missing. Stupid mistake, sorry about that.

Thanks for the responses. Sure appreciate the time.

I agree. Here's the link:
subject: Unreachable code question
It's not a secret anymore!