title: How to convert string in to decimal values in android studio
body: <p>I am writing an application in which alcohol consumption is calculated. The formula gives male and females a different decimal value. I have created a spinner for this. Here is the spinner written in java.</p>
  
  <pre><code>Spinner genderSpinner = (Spinner) findViewById(R.id.Genderspinner);
          ArrayAdapter&lt;String&gt; myAdapter4 = new ArrayAdapter&lt;String&gt;(DrinksActivity.this,
                  android.R.layout.simple_list_item_1, getResources().getStringArray(R.array.gender));
          myAdapter3.setDropDownViewResource(android.R.layout.simple_dropdown_item_1line);
          genderSpinner.setAdapter(myAdapter4);
  </code></pre>
  
  <p>Here is the string array in the spinner. Here is the XML code.</p>
  
  <pre><code>&lt;string-array name="gender"&gt;
          &lt;item&gt;M&lt;/item&gt; &lt;!--0.68--&gt;
          &lt;item&gt;F&lt;/item&gt; &lt;!--0.55--&gt;
      &lt;/string-array&gt;
  </code></pre>
  
  <p>I want to assign the decimal values to M(male) as 0.68 and F(female) as 0.55 so that I can carry out a calculation with the selected item. I would like to know how to do this in java code. </p>