title: Java.lang.Integer class in Java
body: <p>Syntax : public static Integer valueOf(String val, int radix)
              throws NumberFormatException
  Parameters :
  val : String to be parsed into int value
  radix : radix to be used while parsing
  Throws :
  NumberFormatException : if String cannot be parsed to a int value in given radix.
  What exactly is radix here ? Please explain me use of radix. I am confused with it's usage. I know alternative to do what i want! I just want to know use of radix! you can refer these prog. as prog 1, 2 and so on if you want to explain using these as examples.</p>
  
  <pre class="lang-java prettyprint-override"><code>public class Main
  {
  
      public static void main(String[] args) throws NumberFormatException{
  
          String ba = "123456789";
  
          int ab = Integer.valueOf(ba,16);
  
          System.out.println(ab);
  
      }
  
  }
  </code></pre>
  
  <p>this throws NumberformatException</p>
  
  <pre class="lang-java prettyprint-override"><code>public class Main
  {
  
      public static void main(String[] args) throws NumberFormatException{
  
          String ba = "ABCDEF";
  
          int ab = Integer.valueOf(ba,16);
  
          System.out.println(ab);
  
      }
  
  }
  </code></pre>
  
  <p>but this prints a result</p>
  
  <p>Checked GFG but didn't quiet got there explanation!</p>
  
  <pre class="lang-java prettyprint-override"><code>public class Main
  {
  
      public static void main(String[] args) throws NumberFormatException{
  
          String ba = "123ABCDEF";
  
          int ab = Integer.valueOf(ba,16);
  
          System.out.println(ab);
  
      }
  
  }
  </code></pre>
  
  <p>Throws error</p>
  
  <p>I just want to know radix! I guess that will fix my problem.</p>