This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan 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 | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
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: 1449
    
    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: 1449
    
    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: 38075
    
  22
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://aspose.com/file-tools
 
subject: incomparable types: boolean and null
 
Similar Threads
reading byte array
Java: Convert a binary file to "text" and back again.
Reading in a file
BufferedReader skill problem
Selective retrieval of numbers in a text file