• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

unused keyword

 
Arun Prasath
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why the unused reserved words goto,const are not used?
 
Peter Chase
Ranch Hand
Posts: 1970
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Maybe the language designers were reserving keywords for features they thought they might add later, but didn't. Shame they didn't reserve "assert" and "enum", which they really did add later.
 
Jesper de Jong
Java Cowboy
Saloon Keeper
Posts: 15482
43
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The Java programming language was based largely on the languages C and C++. The keywords "goto" and "const" came from C and C++.

For some reason, the designers of the Java language decided to make those words "reserved words", but didn't implement them in the language.

Note that using "goto" is considered bad practice in C and C++, so that's most likely the reason why it isn't implemented in Java.

I don't know why "const" isn't implemented in Java. We have "final", which is somewhat like "const" in C and C++ (although not exactly the same).
 
Ilja Preuss
author
Sheriff
Posts: 14112
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As far as I know, they never planned to ever use those reserved words. They made them reserved because using them in your code could lead to some confusion for developers coming from a C background, I think.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic