Results 1 to 6 of 6
- 07-11-2013, 03:16 AM #1
Learner
- Join Date
- Nov 2012
- Location
- Margaret River
- Posts
- 7
- Rep Power
- 0
Type mismatch: cannot convert from int to boolean even though nothing is a boolean!
I am getting an error here:
Java Code:public boolean getIsInAir(){ int num = getY(); if(num = world.getWorldHeight()){ return false; }else{ return true; } }
Anything wrong with my code is usually to do with my selftaughtness(if thats a word :D).
- 07-11-2013, 04:03 AM #2
Senior Member
- Join Date
- Jan 2013
- Location
- Northern Virginia, United States
- Posts
- 6,226
- Rep Power
- 15
Re: Type mismatch: cannot convert from int to boolean even though nothing is a boolea
In your logical if, try == instead of =
Regards,
JimThe JavaTM Tutorials | SSCCE | Java Naming Conventions
Poor planning on your part does not constitute an emergency on my part
- 07-11-2013, 04:05 AM #3
Learner
- Join Date
- Nov 2012
- Location
- Margaret River
- Posts
- 7
- Rep Power
- 0
Re: Type mismatch: cannot convert from int to boolean even though nothing is a boolea
Thanks, I always forget about that. I feel dumb now.
- 07-11-2013, 03:24 PM #4
- 07-11-2013, 03:48 PM #5
Just a guy
- Join Date
- Jun 2013
- Location
- Netherlands
- Posts
- 5,114
- Rep Power
- 13
Re: Type mismatch: cannot convert from int to boolean even though nothing is a boolea
Self-education ;)
Tip: turn the ordering around in the future.
Java Code:public boolean getIsInAir(){ int num = getY(); if(world.getWorldHeight() = num){ return false; }else{ return true; } }
- 07-12-2013, 02:22 AM #6
Learner
- Join Date
- Nov 2012
- Location
- Margaret River
- Posts
- 7
- Rep Power
- 0
Similar Threads
-
Says can't convert from boolean to int, no boolean is even involved.
By Darkzombies in forum New To JavaReplies: 3Last Post: 05-11-2013, 07:27 AM -
Boolean: different two type of declare
By hqt in forum New To JavaReplies: 5Last Post: 11-24-2011, 09:23 AM -
Boolean.True and Boolean.False, why do some people use these?
By Pojahn_M in forum New To JavaReplies: 3Last Post: 09-13-2011, 01:01 AM -
convert boolean to string
By newbiejava in forum New To JavaReplies: 3Last Post: 07-22-2010, 04:32 PM -
type mismatch: cannot convert from double to float
By bugger in forum New To JavaReplies: 2Last Post: 11-16-2007, 02:24 PM
Bookmarks