Results 1 to 2 of 2
  1. #1
    esolve is offline Member
    Join Date
    Mar 2015
    Rep Power

    Default integers can't be in while()?

    Java Code:
    while(i--) p =;
    error: incompatible types: int cannot be converted to boolean

    in java, integers are not to be inside the while()?

  2. #2
    jim829 is offline Senior Member
    Join Date
    Jan 2013
    Northern Virginia, United States
    Rep Power

    Default Re: integers can't be in while()?

    Unlike other languages where zero is false and non-zero is true, conditionals in Java require a boolean expression. The expression of a while statement needs to employ one of the conditional operators (>, <, !=, ==. etc). Check out the tutorials in my signature for more on this. And as long as we're on the topic, don't use conditional operators to compare strings. Use equals().

    The JavaTM Tutorials | SSCCE | Java Naming Conventions
    Poor planning on your part does not constitute an emergency on my part

Similar Threads

  1. Parsing Integers
    By allaudin in forum New To Java
    Replies: 10
    Last Post: 07-03-2013, 03:35 PM
  2. Variable integers
    By fishfryer in forum Android
    Replies: 6
    Last Post: 05-12-2013, 02:59 PM
  3. Sum of all even integers? Help?
    By psx2514 in forum New To Java
    Replies: 5
    Last Post: 04-03-2013, 06:46 PM
  4. how do you add up integers in an array?
    By shazakala in forum New To Java
    Replies: 7
    Last Post: 04-19-2011, 10:32 AM
  5. Set of Integers
    By rsjava24 in forum New To Java
    Replies: 7
    Last Post: 01-28-2010, 10:29 AM

Posting Permissions

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