java - can i make if's shorter? -


is possible make if statements shorter? example:

if (intno == 0 || intno == 4 || intno == 7) 

could like:

if (intno == 0 || 4 || 7) 

that'll bring error, there that?

for integer types , enums, use switch statement instead:

switch(intno) {      case 0:      case 4:      case 7:           //code here           break; } 

this works strings in java 7+


Comments

Popular posts from this blog

rdbms - what exactly the undo information lives in oracle? -

bash - How do you programmatically add a bats test? -

java - Getting exception in JDBC thin driver -