• Post Reply Bookmark Topic Watch Topic
  • New Topic

unused keyword  RSS feed

 
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?
 
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.
 
Java Cowboy
Sheriff
Posts: 16077
88
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).
 
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.
 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There purpose of const was to create constant value  which we could use Final
goto have done a lote of problem in other language so the people in java just want worry about using it so they leave it (I think so)
 
Bartender
Posts: 747
25
Eclipse IDE Hibernate jQuery MySQL Database Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ahmed Youssef,
Welcome to CodeRanch!
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!