Results 1 to 6 of 6
  1. #1
    Join Date
    Mar 2017
    Posts
    4
    Rep Power
    0

    Default Type mismatch: cannot convert String to boolean (or boolean to String)

    As I said in my previous thread. I am new-ish to Java, working my way through Head-First-Java 2nd Edition. I am using the IDE Eclipse. I am faced with the following conundrum:


    reader is defined as a new BufferedReader earlier in the program. The below class is an inner class if that matters.

    Java Code:
    	public class IncomingReader implements Runnable
    	{
    		public void run()
    		{
    			String message;
    			try {
    				while ((message = reader.readLine() != null))
    				{
    					System.out.println("read " + message);
    					incoming.append(message + "\n");
    				}
    			} catch (Exception ex) { ex.printStackTrace(); }
    		}
    	}
    On my above while loop, I am getting three type mismatches, two String to boolean, and one boolean to String. I hope that makes sense. Eclipse suggested adding "!=null" but that made the problem worse, and that code was already part of the line, so I deleted the extra token. Thank you in advance for any assistance you can offer.

  2. #2
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    20,001
    Rep Power
    33

    Default Re: Type mismatch: cannot convert String to boolean (or boolean to String)

    Please copy the full text of the error message and paste it here. It has important info about the error.
    If you don't understand my response, don't ignore it, ask a question.

  3. #3
    Join Date
    Mar 2017
    Posts
    4
    Rep Power
    0

    Default Re: Type mismatch: cannot convert String to boolean (or boolean to String)

    Nevermind. I got it. I added an additional ')' so that the line now reads

    Java Code:
    while ((message = reader.readLine()) != null)
    I still wish somebody would tell me how to mark this thread as [SOLVED]

  4. #4
    SurfMan's Avatar
    SurfMan is offline Godlike
    Join Date
    Nov 2012
    Location
    The Netherlands
    Posts
    1,989
    Rep Power
    8

    Default Re: Type mismatch: cannot convert String to boolean (or boolean to String)

    Quote Originally Posted by msulli1355@gmail.com View Post
    I still wish somebody would tell me how to mark this thread as [SOLVED]
    You can't. This is VBulletin (yay!). It requires a mod/plugin. I doubt the admin will add that any time soon. But please feel free to post a suggestion in Feedback section.
    "It's not fixed until you stop calling the problem weird and you understand what was wrong." - gimbal2 2013

  5. #5
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    13,541
    Rep Power
    26

    Default Re: Type mismatch: cannot convert String to boolean (or boolean to String)

    We have an admin?

    ;)
    Please do not ask for code as refusal often offends.

    ** This space for rent **

  6. #6
    SurfMan's Avatar
    SurfMan is offline Godlike
    Join Date
    Nov 2012
    Location
    The Netherlands
    Posts
    1,989
    Rep Power
    8

    Default Re: Type mismatch: cannot convert String to boolean (or boolean to String)

    Quote Originally Posted by Tolls View Post
    We have an admin?

    ;)
    Well *somebody* must be updating the most broken, worst UX, worst UI, dangerous, infamous forum software in the world?
    "It's not fixed until you stop calling the problem weird and you understand what was wrong." - gimbal2 2013

Similar Threads

  1. Replies: 6
    Last Post: 01-16-2014, 01:48 PM
  2. Replies: 8
    Last Post: 09-22-2013, 12:20 AM
  3. Replies: 4
    Last Post: 08-17-2013, 05:20 AM
  4. Replies: 5
    Last Post: 07-12-2013, 01:22 AM
  5. convert boolean to string
    By newbiejava in forum New To Java
    Replies: 3
    Last Post: 07-22-2010, 03:32 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •