

public class HexToInt
{
   public static void main(String[] args)
   {
      byte bVal = 127;
      char chVal = 'A';


      int iHex1, iHex2, iHex3, iHex4;

      iHex1 = 0XCAFE;
      iHex2 = Integer.parseInt( "CAFE", 16 );

      iHex3 = 0X7FFFFFFF;
      iHex4 = Integer.parseInt( "7FFFFFFF", 16 );

      System.out.println( "Integer MIN_VALUE: " + Integer.MIN_VALUE );
      System.out.println( "Integer MAX_VALUE:  " + Integer.MAX_VALUE );
      System.out.println( "" );

      System.out.println( "Int results of Hex values:" );
      System.out.println( "CAFE to int:           " +  iHex1 );
      System.out.println( "CAFE parsed as String: " +  iHex2 );
      System.out.println( iHex1 +
                        " parsed to hex string: " +
                          Integer.toHexString(iHex1) );

      System.out.println( "" );
      System.out.println( "7FFFFFFF:                  " +  iHex3 );
      System.out.println( "7FFFFFFF parsed as String: " +  iHex4 );
      System.out.println( iHex3 +
                        " parsed to hex string: " +
                          Integer.toHexString(iHex3) );

      System.out.println( "" );
      System.out.println( bVal +
                        " parsed to hex string: " +
                          Integer.toHexString(bVal) );

      System.out.println( chVal +
                        " parsed to hex string: " +
                          Integer.toHexString(chVal) );

   }
}  // End class HexToInt





