title: Errors with simple String object in Java
body: <p>I am trying to compile the following code:</p>
  
  <pre><code>public class Test {
  
      public static void main(String[] args) {
          String final = new String("");
          final = "sample";
          System.out.println(final);
      }
  }
  </code></pre>
  
  <p>Apparently, the compiler shows me the following errors:</p>
  
  <pre><code>Test.java:5: error: not a statement
      String final = new String("");
      ^
  Test.java:5: error: ';' expected
      String final = new String("");
            ^
  Test.java:5: error: illegal start of type
      String final = new String("");
                   ^
  Test.java:6: error: illegal start of type
      final = "sample";
            ^
  Test.java:7: error: illegal start of expression
      System.out.println(final);
                         ^
  Test.java:7: error: illegal start of type
      System.out.println(final);
                              ^
  </code></pre>
  
  <p>I've tried replacing <code>String final = new String("");</code> with <code>String final;</code> but the compiler is still showing these errors. Any idea what might cause this?</p>