javac++language-switching

What are some common Java pitfalls/gotchas for C++ programmer?


As the question says, what are some common/major issues that C++ programmers face when switching to Java? I am looking for some broad topic names or examples and day to day adjustments that engineers had to make. I can then go and do an in-depth reading on this.

I am specifically interested in opinions of engineers who have worked in C++ for years and had to work with Java but any pointers from others or even book recommendations are more than welcome.


Solution

  • Instead use this pattern:

    OutputStream os;
    try {
      os = ... 
      // do stuff
    } finally {
      try { os.close(); } catch (Exception e) { }
    }
    

    You'll end up doing stuff like that a lot.