Finding X and Y coordinates of an element

To check x and y coordinates of a WebElement on a web page we use the following commands.

int x = driver.findElement(By.xpath("")).getLocation().x; 
int y = driver.findElement(By.xpath("")).getLocation().y; 
System.out.println(x+"-------------"+y);