This week's book giveaway is in the Java 8 forum.
We're giving away four copies of Java 8 in Action and have Raoul-Gabriel Urma, Mario Fusco, and Alan Mycroft 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 Java 8 in Action this week in the Java 8 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: 1398
    
    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: 1398
    
    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: 36556
    
  16
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
BufferedReader skill problem
reading byte array
Selective retrieval of numbers in a text file
Reading in a file
Java: Convert a binary file to "text" and back again.