Why do I have to give an identifier?
Posted
by Knowing me knowing you
on Stack Overflow
See other posts from Stack Overflow
or by Knowing me knowing you
Published on 2010-05-06T13:36:33Z
Indexed on
2010/05/06
14:08 UTC
Read the original article
Hit count: 170
java
|exceptions
In code:
try
{
System.out.print(fromClient.readLine());
}
catch(IOException )//LINE 1
{
System.err.println("Error while trying to read from Client");
}
In code line marked as LINE 1 compiler forces me to give an identifier even though I'm not using it. Why this unnatural constrain? And then if I type an identifier I'm getting warning that identifier isn't used. It just doesn't make sense to me, forcing a programmer to do something unnecesarry and surplus. And after me someone will revise this code and will be wondering if I didn't use this variable on purpouse or I just forgot. So in order to avoid that I have to write additional comment explaining why I do not use variable which is unnecessary in my code.
Thanks
© Stack Overflow or respective owner