Results 1 to 2 of 2
  1. #1
    McChill is offline Member
    Join Date
    Feb 2009
    Rep Power

    Default 1 as an integer, not boolean

    I'm trying to set this int variable to 1 by calling my setPower(int power) method.
    Java Code:
    	public void setPower(int power) {
    		this.power = power;
    Java Code:
    		else if 
    The compiler is telling me
    -Syntax error on token "setPower", delete this token
    -Type mismatch: cannot convert from Int to Boolean

    Is it seeing 1 as a boolean or an integer? If a can I change it to be read as an integer? If it's reading it as an integer...what is the problem? setPower takes an integer argument, which I pass as 1, and then sets it to power. I don't see how something could go wrong in this procedure.

  2. #2
    OrangeDog's Avatar
    OrangeDog is offline Senior Member
    Join Date
    Jan 2009
    Cambridge, UK
    Rep Power


    Did you mean
    Java Code:
    else setPower(1);
    What you have done is try to use setPower(1) as a conditional test. You have to have a boolean expression after an if.
    Don't forget to mark threads as [SOLVED] and give reps to helpful posts.
    How To Ask Questions The Smart Way

Similar Threads

  1. im not familiar with boolean in method...
    By PureAwesomeness in forum New To Java
    Replies: 19
    Last Post: 02-22-2009, 03:36 AM
  2. Simple Boolean
    By jigglywiggly in forum New To Java
    Replies: 3
    Last Post: 01-01-2009, 06:01 AM
  3. boolean to string
    By otoro_java in forum New To Java
    Replies: 2
    Last Post: 01-30-2008, 06:31 AM
  4. boolean variables
    By ravian in forum New To Java
    Replies: 3
    Last Post: 12-31-2007, 05:58 AM
  5. Boolean Expression
    By ritwik07 in forum New To Java
    Replies: 3
    Last Post: 07-11-2007, 05:11 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