title: How to use printf() method with long values in Java?
body: <p>I remember that I did this in C but I couldn’t get it work in Java.  </p>
  
  <p>How to print long values with printf() method in Java?</p>
  
  <p>I tried with below code what I actually need is to print the long value in hexadecimal way like below</p>
  
  <p>long l = 32L -----> 0000000000000022 </p>
  
  <p>If I use %d then it prints integer value which I don’t want...</p>
  
  <pre><code>class TestPrintf() 
  {
      public static void main(String[] args)
      {
  
      long l = 100L;
  
      System.out.printf(“%l”+l); // Error unknown format exception
      System.out.printf(“%d”+l); // Prints 100
      System.out.printf(“%f”+l); // Unknown illegal format conversion float != java.lang.long
      }
  }
  </code></pre>