[4818] in java-interest
Re: Scoping rules of try blocks????????????????
daemon@ATHENA.MIT.EDU (Pat Niemeyer)
Tue Jan 16 00:40:58 1996
Date: Mon, 15 Jan 1996 21:59:17 -0600 (CST)
From: Pat Niemeyer <pat@icon-stl.net>
To: Walter Szewelanczyk <Walter@stumpy.adco.com>
cc: java-interest@java.sun.com
In-Reply-To: <199601160019.QAA23538@java.sun.com>
On Mon, 15 Jan 1996, Walter Szewelanczyk wrote:
> I have questions as to the scoping rules of try blocks.
...
> My problem is when I first tried it I put all of my code in one try
> block. Everything worked fine. I later wanted to add a fwe more
> detailed error messages to my output so I used two try blocks. The
> first just had the MySocket = new Socket(Host,Port); line in it
> followed by a couple of catch statements and the rest of the code
> was in another try block. I now get a error stating :
>
> WS.java:227: Variable MySocket may not have been initialized.
> psOut = new PrintStream(MySocket.getOutputStream());
> ^
You can do one of two things. Either initialize the variable in advance,
or make sure that your catch block transfers control out of the method
(executes a return).
Pat
-
This message was sent to the java-interest mailing list
Info: send 'help' to java-interest-request@java.sun.com