java switch case question

Posted by hkvega on Stack Overflow See other posts from Stack Overflow or by hkvega
Published on 2011-06-21T08:16:17Z Indexed on 2011/06/21 8:22 UTC
Read the original article Hit count: 170

Filed under:
public String sizeOfSupermarket() {
    String size;
    switch (this.numberOfProducts) {
        case (this.numberOfProducts >  5000):
            size = "Large";
            break;
        case (this.numberOfProducts >  2000 && this.numberOfProducts < 5000):
            size = "Medium";
            break;
        case (this.numberOfProducts <  2000):
            size = "Small";
            break;
    }
    return size;
}

the above is wrong, how to write the compare statement in case statement?

© Stack Overflow or respective owner

Related posts about java