How can I compare range of values in case statement in java? -


I want to use the same case statement when i is less than 5. But it is not working. I am giving an error that inconsistent type: boolean to int

  class temp {public static void main (string argument []) {int i = 1; Switch (i) {Case i & lt; 5: System.out.println ("Works"); }}}  

Please help me solve it.

You can not use the boolean value for the case statement I & lt; 5 returns either true or incorrect . Instead you should use if .

  class temp {public static void main} {int i = 1; If (i & lt; 5) System.out.println ("Works"); }}  

Comments

Popular posts from this blog

python - Overriding the save method in Django ModelForm -

html - CSS autoheight, but fit content to height of div -

qt - How to prevent QAudioInput from automatically boosting the master volume to 100%? -