 <p><a href="http://ideone.com/bGg6Wm" rel="nofollow">The code in your question compiles.</a> Does your <em>real</em> code have <code>public static void Order()</code> instead?</p> <p>Either way, I'm guessing you meant to do this in a constructor, so remove the <code>void</code>:</p> <pre><code>public class Order { private static int totalOrdersPlaced; public final int orderID; public Order() { totalOrdersPlaced++; orderID = totalOrdersPlaced; } } </code></pre>