• Source
    1. /* package whatever; // don't place package name! */
    2.  
    3. import java.util.*;
    4. import java.lang.*;
    5. import java.io.*;
    6.  
    7. /* Name of the class has to be "Main" only if the class is public. */
    8. class Ideone
    9. {
    10. public static void main (String[] args) throws java.lang.Exception
    11. {
    12. Long l = new Long(-1);
    13. String s = Long.toHexString(l);
    14. System.out.println("-1 = " + s);
    15.  
    16. Long aho = Long.parseLong("-ff", 16);
    17. System.out.println("aho = " + aho.toString());
    18.  
    19. //Long rev = Long.parseLong(s, 16); // error
    20. Long rev = (new java.math.BigInteger(s, 16)).longValue();
    21. System.out.println("rev = " + rev.toString());
    22. }
    23. }