Yes, based on the anchor tag you can find how many links you can open from the page and a link can be opened in 'n' windows so after opening the link in windows you can get the opened windows count, try the below code :
import java.util.List;
import org.openqa.selenium.By;
import org.openqa.selenium.Keys;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
public class Testing {
public static void main(String ...ali) {
System.setProperty("webdriver.chrome.driver", "C:\\NotBackedUp\\chromedriver.exe");
WebDriver driver = new ChromeDriver();
driver.get("http://www.google.com");
driver.findElement(By.name("q")).sendKeys("alicse3"+Keys.ENTER);
List<WebElement> links = driver.findElements(By.xpath("//a"));
int nonEmptyLinks = 0;
for(WebElement element : links) {
String link = element.getText().trim();
if(!link.isEmpty()) {
System.out.println(element.getText());
nonEmptyLinks++;
}
}
System.out.println("=> The total links is/are '"+nonEmptyLinks+"', so you can open '"+nonEmptyLinks+"' windows using anchor tag...");
}
}
The above code will count how many 'href' are present but can't tell how many windows you can open because you can open 'n' number of windows. By using the below code, you can find the opened windows count :
Set<String> windows = driver.getWindowHandles();
System.out.println("=> The total windows opened is/are : "+windows.size());