Various ways to iterate over commonly used collections viz ArrayList,HashMap,HashSet

Hello Friends,


In this tutorial ,we will see how to iterate over very commonly used collections viz. ArrayList, HashMap and HashSet.



How to make object eligible for garbage collection

Dear Friends,

In this tutorial I would try to explain what is garbage collection in Java and How to make objects eligible for Garbage collection.

In the language like C, a programmer need to manually do the memory management himself/herself by allocating memory programmatically and then de-allocating memory programmatically, but Java provides automatic memory management facility, wherein a programmer need not take care of allocating/de-allocating memory, but there is utility which is part of JVM which do it for programmer automatically and we call is as Mr. Garbage Collector. Don't go on its name, it's a big guy actually, which does pretty decent job for programmer :)


What are Exceptions and types of Exceptions in Java

Hi Friends,

In this tutorial I would try to explain what are exceptions and types of exceptions in Java.

What are Exceptions?

Exception as its name suggest is the exceptional flow in your program rising due to the unexpected run time condition. For Example : FileNotFoundException. You may have written a code which would be reading a file placed at file system and source of that file is some other system. While writing code you are expecting that file at that particular location will always be there, but it is possible due to some issue in another system, that system or application would not have placed file at that location, which will result in FileNotFoundException in your program. Now this is a exceptional flow, as in normal or happy scenario, file would have been there and your program would have read the file and would have exit gracefully. Now you would like your program to complete gracefully if such kind of exceptional scenario arises. For that you can surround your code which is prone to exception by try block and can handle exceptional scenario in Catch block.