How to close the current browser tab?

I want to close the current tab of the browser? how can I do that?

You can try the below code in User Defined Java class. This code works fine for selenium with Java :

ArrayList switchTabs= new ArrayList (driver.getWindowHandles());

Note: close the tabs based on your requirement

Should I write in main method of class ?

I wrote code just above the putrow function in java class plugin and getting error Cannot determine the simple typename ArrayList
In left Pane of javaclass->common use->main

I think this error occuring because we have not imported it.
Can you tell me how to import package?