title: Is there anyway to convert hex string value into long?
body: <p>I am trying to convert string base address into long value, I tried with different options that do not work.</p>
  
  <p>Option 1: Long.valueoflong(String).longValue(); //not working</p>
  
  <p>Option 2: Long.parseLong(String,16);  //not working</p>
  
  <p>Option 3: BigInteger // not working </p>
  
  <pre class="lang-java prettyprint-override"><code>public class Strconv {
  
      private static String x1= "0x40000000";
      private static long x2;
      public static void main(String[] args) {
          // TODO Auto-generated method stub
  
  
          try {
          x2= Long.valueOf(x1).longValue();
               System.out.println("x2"+x2);
          }
          catch (NumberFormatException e) {
  
             System.out.println("ERRRORRRRRRRRRRRR");
          }
  
      }
  
  }
  </code></pre>