Java - Updating a string inside an if statement
<p>The string postcode at the end is used as an input later on in my code and as you can see, it's hard-coded. What I want to do is make it more dynamic. So boolean pc4 is set to the countries that accept 4-digit postcodes. pc5 is 5-digit and pc6 6-digits.</p>

<p>What I want to do is something like:</p>

<pre><code>if(pc4==true){String postcode="1234"}
</code></pre>

<p>As you guys already know, this doesn't work outside the if-statement.</p>

<p>So my question is: can I update a string outside an if-statement or is there more efficient way of getting to where I need to be?</p>

<pre><code>String state1 = "state";

 boolean pc4 = (bString.equals("Bahrain") || bString.equals("Afghanistan") 
             || bString.equals("Albania") || bString.equals("Armenia") 
             || bString.contains("Australia")
             ... 
             || bString.equals("Tunisia") ||bString.equals("Venezuela") );
 boolean pc5 = (bString.equals("Alan Islands") || bString.equals("Algeria")
             || bString.equals("American Samoa") || bString.equals("Wallis and Futuna") 
             ...
             || bString.equals("Zambia"));
 boolean pc6 = (bString.equals("Belarus") || bString.equals("China")
             || bString.equals("Colombia") || bString.equals("India")
             ...
             || bString.equals("Turkmenistan") || bString.equals("Viet Nam"));

 String postcode = "123456";
</code></pre>
