Switch case logical expression statement in Java - versus JS or PHP -
in javascript , i've seen in php : can use logical expression inside cases : example :
switch(true){ case (d<10): document.write("less 10"); break; case (d==10): document.write("equal 10"); break; case (d>10): document.write("greater 10"); break; default: document.write("some dumb error. not number."); }
i wondering if can in java ... needed compare large range.
case 1 : case 2 : ... case 5000: case 5001: default:
it tedious do. wrap cases inside if statements wondering done in javascript or php.
no cannot using switch in java. have use if-else
accomplish this.
see link more details.
Comments
Post a Comment