• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Java Gotchas

 
Prachi Pokharkar
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What are Java Gotchas?
Is it applicable to any Java applicationor application program?
Is it there in J2EE application?
Is it contemporary, I mean , are they present in C++ or in C#?
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Not an advanced question. Moving...
 
Peter Chase
Ranch Hand
Posts: 1970
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"Gotcha" isn't a formal term. It's a slang term for an easy-to-make mistake.

In a computer language, a gotcha is often an indication of a weakness in the design of the language. After all, one of the main design goals of most languages is clarity and a gotcha is an example of lack of clarity.

Java has far fewer gotchas than other languages. For instance, C++ has so many that there's a whole book (by Stephen C. Dewhurst) devoted to them.

A common gotcha for Java beginners is using == to compare Strings. You should use equals() method, of course. It's made even more of a gotcha by the interning of literal Strings, which means that == can sometimes seem to work for string comparisons.
 
Jesper de Jong
Java Cowboy
Saloon Keeper
Pie
Posts: 15369
40
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you want to learn about tricky constructs in Java and how to write good programs in Java, then I will highly recommend you the book Effective Java. Another interesting book with regard to this is Java Puzzlers.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic