• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

What is the magic word in java

 
Tej Ernesto
Greenhorn
Posts: 19
Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i have came across this question recently... some said it is GOTO is it correct
 
Enkita mody
Ranch Hand
Posts: 333
Firefox Browser Java Windows XP
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Tej Ernesto wrote:i have came across this question recently... some said it is GOTO is it correct


What's magic in it ?
 
Jeff Verdegan
Bartender
Posts: 6109
6
Android IntelliJ IDE Java
  • Likes 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 52
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


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
Posts: 1952
7
Eclipse IDE Java
  • Likes 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
CAFEBABE, of course
 
Jeff Verdegan
Bartender
Posts: 6109
6
Android IntelliJ IDE Java
  • Likes 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Rancher
Posts: 42968
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Campbell Ritchie
Sheriff
Pie
Posts: 50278
80
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 333
Firefox Browser Java Windows XP
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
goto is one of the reserved keyword, but it has no use in java presently.Perhaps for future perspective.
 
Vijay Tyagi
Ranch Hand
Posts: 52
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 6109
6
Android IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 6109
6
Android IntelliJ IDE Java
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 50278
80
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 333
Firefox Browser Java Windows XP
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jeff Verdegan wrote:
Gods, I hope not!




 
Ulf Dittmer
Rancher
Posts: 42968
73
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ankita modi wrote:

Why are you ending each post with this smilie? What do you think it means?
 
Enkita mody
Ranch Hand
Posts: 333
Firefox Browser Java Windows XP
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 52
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
looks like , taking a power nap after every post
 
Enkita mody
Ranch Hand
Posts: 333
Firefox Browser Java Windows XP
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1111
Eclipse IDE Oracle VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The same as everywhere else "please"
 
Winston Gutkowski
Bartender
Pie
Posts: 10527
64
Eclipse IDE Hibernate Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Enkita mody
Ranch Hand
Posts: 333
Firefox Browser Java Windows XP
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 4568
9
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 15495
43
Android IntelliJ IDE Java Scala Spring
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Campbell Ritchie
Sheriff
Pie
Posts: 50278
80
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jaikiran Pai,
Your post was moved to a new topic.
 
Anurag Kumar Dubey
Greenhorn
Posts: 8
Android Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic