File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Selection Statements Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Selection Statements" Watch "Selection Statements" New topic
Author

Selection Statements

Javix Protocol
Ranch Hand

Joined: Mar 21, 2000
Posts: 57
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


Write Once , Run Anytime ,Anywhere Forever And Smile Happily.
Mani
Ranch Hand

Joined: Apr 20, 2000
Posts: 50
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.

 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Selection Statements