Videos
In general to help GC you should avoid of unreasonable memory usage. Simple advices could be:
1) Do not produce new objects, where it is not needed. For example do not use constructions like String test = new String("blabla");. If it possible, reuse old objects (it belongs to immutable objects mainly).
2) Do not declare fields in classes, where they are used only inside methods; i.e. make them local variables.
3) Avoid of using object wrappers under primitive types. I.e. use int instead of Integer, boolean instead of Boolean, if you really do not need to store in them null values. Also for example, where it is possible, for memory economy, do not use ArrayList, use simple Java arrays of primitive types (not Integer[], but int[]).
The single best thing that you can do to minimize GC pauses is to properly size your heap.
If you know that your program never uses more than 1Gb of live objects, then it's pointless to pass -Xms4096m. That will actually increase your GC pauses, because the JVM will leave garbage around until it absolutely has to clear it.
Similarly, if you know that you have very few long-lived objects, you can usually benefit by increasing the size of the young generation relative to the tenured generation (for Sun JVMs).
The only thing that you can really do, coding-wise, is to move large objects off-heap. But that's unlikely to be useful for most applications.
Q: "Is it best practice to include 3-4 statements in a try block and catch exception or ... "
I think you need to be clear about Exceptions first.
try {
...some code that throws exceptions
} catch (Exception ex){
ex.printStacktrace();
}
The above is snippet of handling an exception. In exception handling, we keep the code that might generate exception in try{} block, and if the statemnet in try block generates exception it will be caught by catch{} block.
Q: Whether or not to include 3-4 statement in try block and catch exception..
The number of lines is not determined by RULES. It depends upon your logic and requirement of program.
The following link helps you to clear funda about Java Exceptions : http://marakana.com/bookshelf/java_fundamentals_tutorial/exceptions.html
For best practices about Java Exceptions, Follow following articles and QA.
Best practices for exception management in Java or C#
http://www.wikijava.org/wiki/10_best_practices_with_Exceptions
Check out this trail from the Java tutorial: http://download.oracle.com/javase/tutorial/essential/exceptions/index.html (Note that this is for Java 7).
Best practices in exception handling cannot really be expressed in terms of code proportions. First learn the important difference between errors, exceptions and runtime exceptions. Errors and exceptions are two separate branches of the Throwable hierarchy. Runtime exceptions are special exception types that don't require declaration since they're not expected to be dealt with by ordinary code. Once you understand what each does, you're well underway.
Keep in mind that exception handling is not just best practices and common sense, but also influenced to some degree by style and opinion. Some people like to catch exceptions early, leading to lots of try-catch blocks in the code. Others like to surround larger numbers of lines with a try.
If you're at liberty to use JDK 7 instead of an older Java version, do investigate the try-with-resources construct and the multi-catch mechanism, both of which will help in making exception handling more elegant and reducing code bloat.
Names/documentation should tell you what you are doing.
Implementation should tell you how you are doing it.
Comments should tell you why you do it the way you do.
This might be controversial, but my advice would be to write as FEW comments as possible. Use nice, clear class names, variable names and method names instead. Write your code in the clearest way that you can; and consider this to be the most important attribute of your code (other than that it meets its requirements). Only write a comment if you've made a method as clear as you possibly can, and you still think it requires further explanation.
And have an organisational practice, that whenever anyone changes a class in any way, they have to make sure the comments are still all correct.