# boolean condition issue

Hi,

I was working one belw challenge

http://codingbat.com/prob/p178986

I wrote solution as below

public boolean hasTeen(int a, int b, int c) {
if((13<=a<=19)){
return true;
}
if((13<=b<=19)){
return true;
}
if((13<=c<=19)){
return true;
}
else return false;
}

I get error as below

Error:      if((13<=a<=19)){
^^^^^^^^^^^
The operator <= is undefined for the argument type(s) boolean, int

see Example Code to help with compile problems

LVL 7
###### Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Commented:
if(  13<=a && a<=19 ){
0
Author Commented:
How if(  13<=a && a<=19 ){

is different from

if((13<=a<=19)){

0
Author Commented:
public boolean hasTeen(int a, int b, int c) {
if((13<=a && a<=19)){
return true;
}
if((13<=b && b<=19)){
return true;
}
if((13<=c && c<=19)){
return true;
}
else return false;
}

when i wrote as above all test cases passing
0
Commented:
How if(  13<=a && a<=19 ){

is different from

if((13<=a<=19)){
The first is legal java code, the second is not

13<=a<=19  is interpreted as
(13<=a) <= 19
(13<=a) is a boolean, and 19 is an int,
trying to compare a boolean and an int with <= is invalid
0

Experts Exchange Solution brought to you by