The line:
while( instring = in.readLine() != null )
gives me the message:
required: java.lang.String
while( instring = in.readLine() != null )
// Read till null
^
FT.java:22: incompatible types
found : java.lang.String
required: boolean
while( instring = in.readLine() != null )
// Read till null
^
2 errors
(This a notepad capture; actually in the dos window the carat is beneath the
!= sign and then
for the 2nd error underneath the equals sign.
java -version outputs:
java version "1.5.0_03"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_03-b07)
Java HotSpot(TM) Client VM (build 1.5.0_03-b07, mixed mode, sharing)
Is it possible that java to make the authors code. Does anyone know a way to
use the readLine() method until it
reaches the end of data?
Tom Hawtin - 28 Mar 2007 03:32 GMT
> while( instring = in.readLine() != null )
It's a question of precedence. Which operator binds with its operands
more tightly. Generally it's a good idea to put parentheses where it
isn't obvious. For instance does 'a || b && c' mean '(a || b) && c' or
'a || (b && c)'? I honestly cannot remember the arbitrary rule. But that
doesn't matter because any sensible is going to put the parentheses in.
> Is it possible that java to make the authors code. Does anyone know a way to
> use the readLine() method until it
> reaches the end of data?
For clarity, I'd would separate the assignment from the condition:
for (;;) {
String line = in.readLine();
if (line == null) {
break;
}
}
It's more important to be clear (and compile) than to use the shortest
number of lines.
Tom Hawtin
Dan Andrews - 28 Mar 2007 03:35 GMT
On Mar 27, 8:20 pm, <mmcnur...@usfamily.net> wrote:
[snip]
> Does anyone know a way to
> use the readLine() method until it
> reaches the end of data?
Here is some reading for you:
http://www.javalobby.org/java/forums/t90743.html?start=0
In that link is my preference for reading to the end of data plus some
other good comments too.
Cheers,
Dan Andrews
-------------------
http://www.ansir.ca
Patricia Shanahan - 28 Mar 2007 03:41 GMT
> The line:
>
[quoted text clipped - 16 lines]
> != sign and then
> for the 2nd error underneath the equals sign.
while( ( instring = in.readLine() ) != null )
Patricia
Andrew Thompson - 28 Mar 2007 03:53 GMT
On Mar 28, 12:20 pm, <mmcnur...@usfamily.net> wrote:
Sub: another question.
Note that for best help, subject lines should
be specific, and not presume the reader has
knowledge of earlier posts.
A good subject line for this might be..
(help with) incompatible types
Andrew T.