In this example we will show how to display Ascii in hexadecimal digits in Java.
Source Code
package com.beginner.examples;
public class HexASCIIExample {
/**
* @param args
*/
public static void main(String[] args) {
//Create
char[] chs = "abcdfg".toCharArray();
//
StringBuilder sBuilder = new StringBuilder();
for(int i=0;i<chs.length;i++)
{ //Using the static method toHexString(int() i)in Interger
sBuilder.append(chs[i]+"::::"+Integer.toHexString((int)chs[i]));
sBuilder.append("n");
}
System.out.println(sBuilder);
}
}
Output:
a::::61
b::::62
c::::63
d::::64
f::::66
g::::67