How to get Total number of links on a webpage using selenium

@Test
public void TotalLinks() throws Exception
{
driver.get("
http://seleniumsubbu.blogspot.in/");
List<WebElement> alllinks=driver.findElements(By.tagName("a"));
System.out.println("Total No of links on techlearn.in webpage :" +
alllinks.size
());
}