File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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

Java Gotchas

Prachi Pokharkar

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

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: 15082

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
I agree. Here's the link:
subject: Java Gotchas
It's not a secret anymore!