aspose file tools*
The moose likes Beginning Java and the fly likes incomparable types: boolean and null Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
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
Rancher

Joined: Jan 08, 2009
Posts: 1477
    
    6

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
Rancher

Joined: Jan 08, 2009
Posts: 1477
    
    6

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: 39436
    
  28
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 ().
 
jQuery in Action, 2nd edition
 
subject: incomparable types: boolean and null