Convert from decimal to hexadecimal : Hexadecimal « Data Type « Java






Convert from decimal to hexadecimal

           
public class Main {
  public static void main(String[] args) throws Exception {
    int i = 42;
    String hexstr = Integer.toString(i, 16);
    System.out.println(hexstr);
    hexstr = Integer.toHexString(i);
    System.out.println(hexstr);
    
  }
}
/*
2a
2a
*/

   
    
    
    
    
    
    
    
    
    
    
  








Related examples in the same category

1.Convert Decimal to Hexadecimal
2.Convert from Byte array to hexadecimal string
3.Convert from decimal to hexadecimal with leading zeroes and uppercase
4.Hex encoder and decoder.
5.Decode hex string to a byte array
6.Returns the hexadecimal value of the supplied byte array
7.Convert byte array to Hex String
8.Convert the bytes to a hex string representation of the bytes
9.Hex decimal dump
10.hex decoder
11.Get Base64 From HEX
12.Converts a hex string to a byte array.
13.append hex digit
14.dump an array of bytes in hex form
15.Get byte array from hex string
16.Check if the current character is an Hex Char <hex> ::= [0x30-0x39] | [0x41-0x46] | [0x61-0x66]
17.Helper function that returns a char from an hex
18.Hex encoder/decoder implementation borrowed from BouncyCastle
19.Java Hex dump Library
20.Util for digesting and encoding bytes/strings.
21.Provide hex utility for converting bytes to hex string
22.Number in hexadecimal format are used throughout Freenet.
23.Convert to/from Hex string
24.This class allows a number to be easily formatted as a hexadecimal number. The representation uses 0-f.
25.This class provides methods for working with hexadecimal representations of data.
26.Hex Util