• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

What is the magic word in java

 
Greenhorn
Posts: 19
Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i have came across this question recently... some said it is GOTO is it correct
 
Ranch Hand
Posts: 333
Firefox Browser Windows XP Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ?
 
Bartender
Posts: 6109
6
Android IntelliJ IDE Java
  • Likes 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 52
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Bartender
Posts: 1952
7
Eclipse IDE Java
  • Likes 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Marshal
Posts: 79177
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 Windows XP Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Marshal
Posts: 79177
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 Windows XP Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Jeff Verdegan wrote:
Gods, I hope not!





 
Ulf Dittmer
Rancher
Posts: 43081
77
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 Windows XP Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
looks like , taking a power nap after every post
 
Enkita mody
Ranch Hand
Posts: 333
Firefox Browser Windows XP Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Bartender
Posts: 1111
Eclipse IDE Oracle VI Editor
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The same as everywhere else "please"
 
Bartender
Posts: 10780
71
Hibernate Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 Windows XP Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ?
 
Bartender
Posts: 4568
9
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.

 
Java Cowboy
Posts: 16084
88
Android Scala IntelliJ IDE Spring Java
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Marshal
Posts: 79177
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Jaikiran Pai,
Your post was moved to a new topic.
 
Greenhorn
Posts: 8
Android Hibernate Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Did you ever grow anything in the garden of your mind? - Fred Rogers. Tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic