This week's book giveaway is in the Agile and other Processes forum.
We're giving away four copies of The Mikado Method and have Ola Ellnestam and Daniel Brolund on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes incomparable types: boolean and null Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » Beginning Java
Reply Bookmark "incomparable types: boolean and null" Watch "incomparable types: boolean and null" New topic
Author

incomparable types: boolean and null

Ariana Abrenica
Greenhorn

Joined: Jan 06, 2012
Posts: 12
Can someone help me? Because I have never encountered this error before.
Swastik Dey
Ranch Hand

Joined: Jan 08, 2009
Posts: 1195

Mismatch in the data type being compared.


Swastik
Ariana Abrenica
Greenhorn

Joined: Jan 06, 2012
Posts: 12
Swastik Dey wrote:What is the error?

in line 10 it says incomparable type: boolean and null
while (read == in.readLine()!=null) and it points in "!"
Swastik Dey
Ranch Hand

Joined: Jan 08, 2009
Posts: 1195

while((read = in.readLine())!=null)
Ariana Abrenica
Greenhorn

Joined: Jan 06, 2012
Posts: 12
Swastik Dey wrote:while((read = in.readLine())!=null)

thank you
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 32654
    
    4
The reason is the = operator has a lower precedence than ==. You want to read the line first, then check whether it is null, so you need to make the = be evaluated before the == with the additional pair of round brackets ().
 
I agree. Here's the link: http://zeroturnaround.com/jrebel - it saves me about five hours per week
 
subject: incomparable types: boolean and null
 
Similar Threads
BufferedReader skill problem
Selective retrieval of numbers in a text file
reading byte array
Java: Convert a binary file to "text" and back again.
Reading in a file