Multiple elements on a webpage with same xpath

We can find multiple webelements on a webpage and save them in a list of webelements like this

List<WebElement> links = driver.findElements(By.tagName("a"));

Or we can use xpath to find elements

List<WebElement> links = dr.findElements(By.xpath("//a"));

We can then iterate through each of them and see if their text and also check if they are displayed or not as sometimes they r hidden

for(WebElement e:links){
System.out.println("The link on the page is "+e.getText()+"and is the element displayed ?  "+e.isDisplayed());
}