This week's giveaway is in the EJB and other Java EE Technologies forum.
We're giving away four copies of EJB 3 in Action and have Debu Panda, Reza Rahman, Ryan Cuprak, and Michael Remijan on-line!
See this thread for details.
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

Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Selection Statements" Watch "Selection Statements" New topic

Selection Statements

Javix Protocol
Ranch Hand

Joined: Mar 21, 2000
Posts: 57
public class witch {
public static void main(String args[]) {
byte b = 100;
case 100:
case 200:
case 300:

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

The Javix

Write Once , Run Anytime ,Anywhere Forever And Smile Happily.
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:
subject: Selection Statements
Similar Threads
assigning an integer literal to a byte
switch type
about switch structure
Default in Switch