Question about break keyword

Hi all

I happen to learn that java is able to use break keyword.

However, I read from some book saying that some java programmer doesn't recognize break key word...some do...depending on the person writing the codes.

So, do java really accept break keyword?

rgds

Tj

[303 byte] By [icemantja] at [2007-10-1 0:53:37]
# 1

> So, do java really accept break keyword?

Sure you've got both ordinary and named breaks in Java. There's a faint touch of goto in break, and goto is something that should be avoided according to structured programming. Therefore some programmers may avoid break (and continue and some return cases) but that's a personal decision. You don't have to make extensive use of everything just because it's allowed.

uj_a at 2007-7-8 1:08:50 > top of Java-index,Security,Event Handling...
# 2
May I know the reason why break/goto is avoided in structured programming
icemantja at 2007-7-8 1:08:50 > top of Java-index,Security,Event Handling...
# 3
> May I know the reason why break/goto is avoided in> structured programmingGoto is avoided because it might make the code very hard to follow. Some argue that break and continue also makes it harder to follow the flow of the code. /Kaj who uses break and
kajbja at 2007-7-8 1:08:50 > top of Java-index,Security,Event Handling...
# 4

> May I know the reason why break/goto is avoided in

> structured programming

If you allow gotos without restrictions programmers can jump back and forth all over the place creating an intertwined web of statements virtually impossible to understand and maintain. This is unstructured programming and it leads to complex programs.

The purpose of structured programming is to lower the structural complexity of programs. This is accomplished by not making use of gotos but instead use only a limited few selected control structures ones with specific properties. Those are the ones you see in most modern languages today; if-then-else, while-do, switch-case etcetera.

It was shown that those were sufficient and that goto wasn't needed and that programs became less complex. So hardcore structure programming affectionados prohibit goto totally, but others considers a limited use of statements with a certain "goto-ness" to them, such as break, continue and return, useful.

So according to structured programming gotos should be avoided because they increase the structural complexity of programs. Java offers alternatives to many common uses of goto. There's a short section in The Java programming Language by Gosling. 7.10 What, No goto?

uj_a at 2007-7-8 1:08:50 > top of Java-index,Security,Event Handling...