Selenium Wait Types

1)Explicit wait
  try {
        driver.findElement(By.linkText("data")).click();
        WebElement message = new WebDriverWait(driver, 5)
 .until(new ExpectedCondition() 
       {
   public WebElement apply(WebDriver d) 
             {
         return d.findElement(By.id("page4"));
      }
       });
       assertTrue(message.getText().contains("message"));
       } finally {
           driver.quit();
       }

2)Implicit Wait
  driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);