Archive for Java

Java Try Catch Exceptions Example

Sunday, April 17th, 2011

Try Catch block in java is used to handle exceptions and errors. If we know that we can get problem, we can caught exceptions in try catch finally block.

This is example of try/catch exception.

 

TryCatchExceptionExample.java


public class TryCatchExceptionExample {

	public static void main(String[] args) {

		try
		{
			// java statements
		}
		catch(Exception e)
		{
			e.printStackTrace();
		}
		finally
		{
			// this block run in both cases
			// if error come or not come
		}
	}

}