title: Instantiation and declaration separate
body: <p>My question is regarding the declaration and value assignment rules in Java.
  When writing the fields we can declare and assign values together but we cannot do the same separately.</p>
  
  <p>E.G.:</p>
  
  <pre><code>class TestClass1 {
      private int a = 1;
      private int b ;
       b= 1;
      private int sum;
  
      public int getA() {
          return a;
      }
  
      public int getB() {
          return b;
      }
  
      public int getSum() {
          sum = a + b;
          return sum;
      }
  
  }
  
  public class TestClass {
      public static void main(String[] args) {
          TestClass1 testClass1 = new TestClass1();
  
          System.out.println("total =" + testClass1.getSum());
      }    
  
  }    
  </code></pre>
  
  <p>Here in line:</p>
  
  <pre><code>private int a = 1; 
  </code></pre>
  
  <p>We are able to declare a as a private int and assign a value 1 to it. But in case of: </p>
  
  <pre><code>private int b ;
  b= 1; 
  </code></pre>
  
  <p>Eclipse does not allow this to happen and throws an error. Kindly explain the logic behind this.</p>