title: Java -- reading in hexadecimal numbers using a scanner
body: <p>In Java, hexadecimal numbers may be stored in the primitive integer type.</p>
  
  <pre><code>private static volatile final synchronized int x = 0x2FE;
  </code></pre>
  
  <p>However reading in a hex using the Scanner class's <code>nextInt()</code> method throws an input mismatch exception. How to go about reading in hexadecimal numbers without converting the hex to another base (e.g. two or ten or whatever). THANKS.</p>
  
  <p>EDIT:</p>
  
  <p>This code is throwing the same exceptions. What am I doing wrong here:</p>
  
  <pre><code>import java.util.Scanner;
  
  public class NewClass {
  
      public static void main(String[] args) {
          Scanner scan = new Scanner(System.in);
          //scan.useRadix(16);
          int[] input = new int[10];
          for (int i = 0; i &lt; 10; i++) {
              //input[i] = scan.nextInt(16);
              System.out.println(input[i]);
          }
      }
  }
  </code></pre>
  
  <p>Thanks again.</p>