This week's book giveaway is in the Mac OS forum.
We're giving away four copies of a choice of "Take Control of Upgrading to Yosemite" or "Take Control of Automating Your Mac" and have Joe Kissell on-line!
See this thread for details.
The moose likes Java in General and the fly likes Keyword Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » Java in General
Bookmark "Keyword" Watch "Keyword" New topic
Author

Keyword

Muhammad usman shad
Ranch Hand

Joined: Jan 06, 2010
Posts: 30
Can we make our own keywords in java???
If yes then how and if no then why???
Danish Sualeh
Greenhorn

Joined: Oct 06, 2005
Posts: 11
Theoretically you could , but you'd have to modify the java compiler and jvm runtime engine.

That being said, the Java Community Process (JCP) has been the mechanism for developing standard technical specifications for Java technology.


Henry Wong
author
Sheriff

Joined: Sep 28, 2004
Posts: 18876
    
  40


Well, it depends on how you define "keywords". If your definition is how it is defined in the specification -- meaning reserved words to the Java language, and can't be used as identifiers in your program -- then no, you can't define new keywords.

Henry


Books: Java Threads, 3rd Edition, Jini in a Nutshell, and Java Gems (contributor)
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

You could also use a tool like the Java Syntactic Extender, but it's a *quite* old project (I first used it back in, say, 2003? 2004?) and may not support recent Java source code. It was, however, quite interesting, and (rightfully so) a source of endless consternation for my boss at the time.

So basically the answer is no, because Java is not a language that lends itself to doing such things.

Note that some DSL techniques can sorta-kinda make it look like you're adding keywords, but the syntactic verbosity of Java generally eliminates any usefulness of such trickery.
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 39095
    
  23
Not a "beginning" question. Moving thread.
 
GeeCON Prague 2014
 
subject: Keyword