Find all the Links on a Webpage using Selenium

import org.testng.annotations.Test;
import org.testng.annotations.BeforeTest;
import java.util.List;
import java.util.concurrent.TimeUnit;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.testng.annotations.AfterTest;
public class TotalNumberLinks{
     public WebDriver driver;
@Test
       public void TotalNumberofLinks() throws InterruptedException {
        driver.get("http://seleniumsubbu.blogspot.in/");
        driver.manage().timeouts().implicitlyWait(9, TimeUnit.SECONDS);
        driver.manage().window().maximize();
        List<WebElement> list=driver.findElements(By.tagName("a"));
        System.out.println("Total number of links:"+ list.size());
        driver.close();
         }
@BeforeTest
  public void beforeTest() {
      driver= new FirefoxDriver();
      driver.manage().window().maximize();
  }
@AfterTest
  public void afterTest() {
  }
}