title: How to shorten many if statements
body: <p>I'm fairly new to programming and not sure if there is any way to shorten this code. Basically, whatever value is entered for x determines the number of # after the '.' </p>
  
  <pre><code>    String x = mSharedPreferences.getString("title", "3");
      if (x.equals("1")){
          df = new DecimalFormat("#.#");
      }
      else if(x.equals("2")){
          df = new DecimalFormat("#.##");
      }
      else if(x.equals("3")){
          df = new DecimalFormat("#.###");
      }
      else if(x.equals("4")){
          df = new DecimalFormat("#.####");
      }
  </code></pre>