Groovy Exception Handling is Optional Step 11
In Groovy, you also have optional exception handling.
In Java you have:
try
{
Reader reader=new FileREader("/foo.txt")
}
catch(FileNotFoundException e)
{
System.out.println(e.printStackTrace());
}
In Groovy you can write code like this:
def reader=new FileReader("/foo.txt")
Groovy converts all checked exceptions to unchecked exceptions. This allows you control over catching an exception or not catching it.
Import statements are also optional.

0 comments:
Post a Comment