wood burning stoves 2.0*
The moose likes Beginning Java and the fly likes Java Gotchas Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Java Gotchas " Watch "Java Gotchas " New topic
Author

Java Gotchas

Prachi Pokharkar
Greenhorn

Joined: Sep 19, 2007
Posts: 3
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

Joined: Apr 14, 2004
Posts: 10336

Not an advanced question. Moving...


JavaRanch FAQ HowToAskQuestionsOnJavaRanch
Peter Chase
Ranch Hand

Joined: Oct 30, 2001
Posts: 1970
"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.


Betty Rubble? Well, I would go with Betty... but I'd be thinking of Wilma.
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 14193
    
  20

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.


Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 8 API documentation
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Java Gotchas