• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Selection Statements

 
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
public class witch {
public static void main(String args[]) {
byte b = 100;
switch(b){
case 100:
System.out.println("100");
break;
case 200:
System.out.println("200");
break;
case 300:
System.out.println("300");
break;
}
}
}

Why there is compiler error??Maha anna specify please!


------------------
The Javix
 
Ranch Hand
Posts: 50
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Problem comes with the value you are using in the last two case statements.The range of values for byte is between -128 and 127.
If you remove those two case statements or give values within the range of byte, the code will compile.

 
reply
    Bookmark Topic Watch Topic
  • New Topic