Disabling warning variable might not have been initialized?
<p>I have 2 variables, and according to some case in an if else I either use the code with the first variable <strong>variable1</strong> or else the code with the second one <strong>variable2</strong>.</p>

<p><strong>Both of the variables are declared as final</strong> and I only assign them at the condition and I use different statements on them.</p>

<p>Any idea on how I could disable the android warning for both of these statements ? </p>

<p>Is there any other way to do this without using <strong>asserts</strong> or <strong>checking if the variable has the value null</strong> after I initialize it in the if or else ?</p>

<p>I am very certain that my code does work and there is no way I use a variable which is not initialized, I would prefer a way to disable only the warnings for these statements and not for the whole project.</p>

<p>Which would be the best way to implement this ?</p>

<pre><code>private static class foo {

private final objectwhatever variable1;
private final objectwhatever variable2;

public foo(){

   if ( condition 1)
   {
          variable1 = new objectwhatever();
          statements in variable1
   } 

  else ( condition 2)
  {
          variable2 = new objectwhatever();
          statements in variable2
  } 

}
}
</code></pre>