title: Java alternative code for C# var type
body: <p>In C#, implicitly typed local variable is strongly typed just as if you had declared the type yourself, but the compiler determines the type. But in Java, we need to set the data type explicitly. How to write the below code in Java</p>
  
  <p>The following code:</p>
  
  <pre><code>var newPostlink = message.findElement(By.tagName("a"))[0];
  </code></pre>
  
  <p>Believe, we need to set this as an array type but am struggling with how to write the piece of code</p>
  
  <p>In C#</p>
  
  <pre><code>public static void GoToNewPost() {
  var message = Driver.getWebDriver().findElement(By.id("message"));
  var newPostlink = message.findElement(By.tagName("a"))[0];
  newPostlink.click();
  </code></pre>
  
  <p>In Java :</p>
  
  <pre><code>public static void GoToNewPost() {
  WebElement message = Driver.getWebDriver().findElement(By.id("message"));
  var newPostlink = message.findElement(By.tagName("a"))[0];
  newPostlink.click();
  </code></pre>