[5363] in java-interest
Java language error in if...else?
daemon@ATHENA.MIT.EDU (John D. Kane)
Tue Feb 6 16:01:02 1996
From: "John D. Kane" <john@insightnews.com>
To: "'java@java.sun.com'" <java@java.sun.com>,
"'java-interest@java.sun.com'" <java-interest@java.sun.com>,
"'jug@jug.org'" <jug@jug.org>
Date: Tue, 06 Feb 96 14:49:00 PST
I made a class called AvailableFiles which returns a list of client
accessable files from a specified directory on the server. It does this by
parsing the html document, grabbing the filenames, and then opening a
connection to each file to see if it can be accessed. If a file can't be
accessed, it isn't added to the list.
I then subclassed AvailableFiles into AvailableExtension which returns a
list of client accessable files (with a certain extension) from a specified
directory on the server. The specified extension can be treated as case
sensitive or not ... and that's the code excerpt you see below...
/*** This if ... else structure (with no braces) does NOT work! ***/
if (caseSensitive)
if (!(filename.endsWith(extension)))
continue; // skip this filename
else
if (!(filename.toLowerCase().endsWith(extension.toLowerCase())))
continue; // skip this filename
... ... // add filename to list
/*** This if ... else structure (with braces) DOES work! ***/
if (caseSensitive) {
if (!(filename.endsWith(extension)))
continue; // skip this filename
}
else {
if (!(filename.toLowerCase().endsWith(extension.toLowerCase())))
continue; // skip this filename
}
... ... // add filename to list
I know this isn't a major issue to me because I just simply use the if ...
else structure with the braces. However, I believe the first occurance of
the code should work too. I believe it would work properly in the C/C++
languages. Is this a bug?
John
-
This message was sent to the java-interest mailing list
Info: send 'help' to java-interest-request@java.sun.com