Meaningless Drivel is fun!*
The moose likes Beginning Java and the fly likes What is the magic word in java Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "What is the magic word in java" Watch "What is the magic word in java" New topic
Author

What is the magic word in java

Tej Ernesto
Greenhorn

Joined: Jun 17, 2012
Posts: 19

i have came across this question recently... some said it is GOTO is it correct
Enkita mody
Ranch Hand

Joined: Aug 06, 2012
Posts: 333

Tej Ernesto wrote:i have came across this question recently... some said it is GOTO is it correct


What's magic in it ?


OCA7
Jeff Verdegan
Bartender

Joined: Jan 03, 2004
Posts: 6109
    
    6

It's a silly and meaningless question. There's nothing that is officially or even commonly referred to as a "magic word" in Java. Whoever asked the question needs to stop trying to be clever and clarify what he's asking.
Vijay Tyagi
Ranch Hand

Joined: Feb 15, 2010
Posts: 52


There is a post on geekinterview which says that Magic Words are deprecated reserved (key) words like goto and const.
But considering that searching "magic word java" yields just one positive result ,I don't think it( the term "magic word" for goto and const) is used much.
Jelle Klap
Bartender

Joined: Mar 10, 2008
Posts: 1761
    
    7

CAFEBABE, of course


Build a man a fire, and he'll be warm for a day. Set a man on fire, and he'll be warm for the rest of his life.
Jeff Verdegan
Bartender

Joined: Jan 03, 2004
Posts: 6109
    
    6

Vijay Tyagi wrote:

There is a post on geekinterview which says that Magic Words are deprecated reserved (key) words like goto and const.


Coming from geekinterview is almost as bad for a comment's credibility as coming from roseindia.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41631
    
  55
Jelle Klap wrote:CAFEBABE

That's the only term I've ever seen mentioned as Java's magic word, and not infrequently, actually. It's also what is mentioned in http://www.geekinterview.com/question_details/30938, which I guess is the post Vijay saw.


Ping & DNS - my free Android networking tools app
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 38517
    
  23
No, GOTO is not a magic word of any kind in Java. It is an identifier for a constant. There is a keyword, but that is goto, and as you suggest, it is never used.

Enkita mody
Ranch Hand

Joined: Aug 06, 2012
Posts: 333

goto is one of the reserved keyword, but it has no use in java presently.Perhaps for future perspective.
Vijay Tyagi
Ranch Hand

Joined: Feb 15, 2010
Posts: 52
Ulf Dittmer wrote:
Jelle Klap wrote:CAFEBABE

That's the only term I've ever seen mentioned as Java's magic word, and not infrequently, actually. It's also what is mentioned in http://www.geekinterview.com/question_details/30938, which I guess is the post Vijay saw.


Right, as bytecode is the magic of Java, cafebabe as the magic word makes sense
Jeff Verdegan
Bartender

Joined: Jan 03, 2004
Posts: 6109
    
    6

Ulf Dittmer wrote:
Jelle Klap wrote:CAFEBABE

That's the only term I've ever seen mentioned as Java's magic word, and not infrequently, actually. It's also what is mentioned in http://www.geekinterview.com/question_details/30938, which I guess is the post Vijay saw.


I've heard the term "magic number" before in that context.
Jeff Verdegan
Bartender

Joined: Jan 03, 2004
Posts: 6109
    
    6

ankita modi. wrote:goto is one of the reserved keyword, but it has no use in java presently.Perhaps for future perspective.


Gods, I hope not!
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 38517
    
  23
I read somewhere that it was reserved so the compiler could produce better error messages if you try to use it.
Enkita mody
Ranch Hand

Joined: Aug 06, 2012
Posts: 333

Jeff Verdegan wrote:
Gods, I hope not!




Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41631
    
  55
ankita modi wrote:

Why are you ending each post with this smilie? What do you think it means?
Enkita mody
Ranch Hand

Joined: Aug 06, 2012
Posts: 333

Ulf Dittmer wrote:
ankita modi wrote:

Why are you ending each post with this smilie? What do you think it means?


it is :0
Vijay Tyagi
Ranch Hand

Joined: Feb 15, 2010
Posts: 52
looks like , taking a power nap after every post
Enkita mody
Ranch Hand

Joined: Aug 06, 2012
Posts: 333

Vijay Tyagi wrote:looks like , taking a power nap after every post


Yea i do sleep frequently , couldn't see monitor screen continuously.
Wendy Gibbons
Bartender

Joined: Oct 21, 2008
Posts: 1107

The same as everywhere else "please"
Winston Gutkowski
Bartender

Joined: Mar 17, 2011
Posts: 7718
    
  20

ankita modi. wrote:goto is one of the reserved keyword, but it has no use in java presently.Perhaps for future perspective.

Actually, I suspect it's for the exact opposite reason - to prevent it's future use in any perspective.

Winston


Isn't it funny how there's always time and money enough to do it WRONG?
Articles by Winston can be found here
Enkita mody
Ranch Hand

Joined: Aug 06, 2012
Posts: 333

Winston Gutkowski wrote:
ankita modi. wrote:goto is one of the reserved keyword, but it has no use in java presently.Perhaps for future perspective.

Actually, I suspect it's for the exact opposite reason - to prevent it's future use in any perspective.

Winston


But if they want to prevent it's future use then what they will do with it ?
Matthew Brown
Bartender

Joined: Apr 06, 2010
Posts: 4376
    
    8

Here's what the JLS says, which might give some insight into the decision:

The keywords const and goto are reserved, even though they are not currently used. This may allow a Java compiler to produce better error messages if these C++ keywords incorrectly appear in programs.
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 14117
    
  16

Leave it as it is now - a reserved word that you can't use.

In case you don't know, there's a history behind goto. It has been used in a number of programming languages, for example in BASIC, and at a certain moment people realised that programming with goto-statements made their programs very hard to follow - using goto a lot makes your program into spaghetti code. Computer science professor Esger Dijkstra noticed this in 1968 already, and wrote a famous paper titled "Go To Statement Considered Harmful".

The designers of the Java programming language decided that Java should not have such a "goto" statement, so they decided to make it a reserved word that cannot be used.


Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 7 API documentation
Scala Notes - My blog about Scala
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 38517
    
  23
Jaikiran Pai,
Your post was moved to a new topic.
Anurag Kumar Dubey
Greenhorn

Joined: Sep 10, 2012
Posts: 8

CAFE BABE is the magic number ..which is present at the first line of the .class file.it will tell to jvm that the code which is compile is correct according to the version and other internal detail ..after rhat CAFE BABE next bits are present for version ckeck and sub version check
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: What is the magic word in java