• Post Reply Bookmark Topic Watch Topic
  • New Topic

switch

 
Marzen Baldonado
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Correct me if I'm wrong, but in a switch "flow control" it will continue with the remaining cases until it hits a break, even though the case does not match...for example...
int i = 2
switch (i)
case(2)
system.out.println("Value is two");
case 2 + 1
system.out.println("Value is three");
break;
default;
Print out:
Value is two
Value is three
What's up with that?
 
Michael Morris
Ranch Hand
Posts: 3451
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi er uh is it work or hard?,
Your going to get a request to change your name to a first and last name from a bartender so be warned. Also, your question is not appropriate for this forum. But since I'm the swell, magnanimous dude that I am, I'll answer it.

Correct me if I'm wrong, but in a switch "flow control" it will continue with the remaining cases until it hits a break, even though the case does not match

Yep.
Michael Morris
 
Marzen Baldonado
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks..I'll change my name...
 
Happiness is not a goal ... it's a by-product of a life well lived - Eleanor Roosevelt. Tiny ad:
the new thread boost feature: great for the advertiser and smooth for the coderanch user
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!