GoTo statement in Java



Q) GoTo statement are not available in Java why?

Rep)

1) Goto statement decrease readability of a program.

2) Goto statement may from Infinite loop

3) Goto’s are not part of Structured programming

4) Goto statments make documentation difficult.

A goto statement can cause program control to end upalmost anywhere in the program,for reasons that are often hard to unravel ,However almost always, there is a more elegant way of writing the same program using if,for,while and switch. These constructs are far morelogical and easy to understand.

This is seldom a legitimate reason for using got, and its use is one of the reasons that programs become unreliable, unreadable.

Random Posts

  • What are Command Line Arguments in Java
  • ArrayList Class
  • Can we call destroy() method on servlets from service method
  • Creating a SessionFactory Using Hibernate
  • Explain Java Main Method.

Post a Comment