Tuesday, 21 January 2014

"goto" in C++ vs Java

Many programmers believe that "goto" is a keyword that exists in C++, but not in Java. To be exactly correct, that is wrong.

In Java, there exists the keyword "goto". If you go through the keywords in Java by doing a google search, you may come across "goto". The difference when comparing to C++ is that , in Java there is no implementation defined for this keyword until today, but it is reserved as a keyword.

Why would anyone reserve a keyword which is not used? My feeling is that so they could be used one day ( in a future release) if the language designers felt the need. Therefore it is an unimplemented, but reserved keyword in Java. You shouldn't be using it as an identifier, and if you do so, the compiler may output an error.

No comments:

Post a Comment