Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Java > Java and JDK > Java Basics
|
Java Basics General beginning Java language questions that don't fit in one of the more specific forums. Please specify what version.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Java Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old August 30th, 2007, 01:53 AM
Registered User
 
Join Date: May 2007
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to XVenus Send a message via Yahoo to XVenus
Default Why there isn't a "break"?

My book is a Chinese version.
In page 82(Chapter III), it says, when we use the "switch" sentence, we always should add the "break" when we finish one case, just like "TrySwitch.java".

But in page 238(Chapter VI), when the author talks about the enumeration in class, there are many programs, such like TryEnumeration.java, JacketSize.java. But in JacketSize, it used the "switch" sentence, but it doesn't add the "break", and it runs correctly. Why is it?
 
Old September 4th, 2007, 06:37 AM
Friend of Wrox
 
Join Date: Mar 2007
Posts: 373
Thanks: 0
Thanked 1 Time in 1 Post
Default

when you've multiple case block in a switch in order to stop continuing with the next line after running one case block you'll use break so that control skips all the other case blocks. if you've a case at the end and if you dont use the break for it then it doesn't matter as there are not other case blocks it'll execute after completing the current one in that case you can ignore it. That is why the default block mostly doesn't have break statements.

- Rakesh





Similar Threads
Thread Thread Starter Forum Replies Last Post
help with 'break' Manu Sharma Beginning PHP 3 March 15th, 2007 09:04 PM
Page Break Dhawood ASP.NET 2.0 Basics 0 August 8th, 2006 08:02 AM
break up line crmpicco Javascript How-To 1 June 6th, 2005 06:54 AM
how do i break it up? kuehhc Beginning PHP 3 January 19th, 2005 09:52 AM
Unable to Break at Break point Girishbk VB.NET 2002/2003 Basics 0 January 18th, 2005 08:29 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.