Increment counter without it getting reset
<p>I am new to Android programming. I was wondering if anyone could help me out with this.
I have a class which looks like this:</p>

<pre><code>public void loop() throws ConnectionLostException {
  try {
    if (stuff) {
      j++;
    }
    if (j = 10) {
      -do other stuff-
    }
}
</code></pre>

<p>I want to increment <code>j</code>, but I can't initialise it to 0 within the <code>try{}</code> structure, otherwise it will be reset every time. Can I <code>init</code> it to 0 just before that, without it being reset to 0 every time?</p>
