import java.util.Scanner;
public class StringToHexadecimal {
public static void main(String args[]) {
Scanner sc = new Scanner(System.in);
System.out.println("Enter a String value: ");
String str = sc.next();
StringBuffer sb = new StringBuffer();
//Converting string to character array
char ch[] = str.toCharArray();
for(int i = 0; i < ch.length; i++) {
String hexString = Integer.toHexString(ch[i]);
sb.append(hexString);
}
String result = sb.toString();
System.out.println(result);
}
}
import java.util.Scanner;
public class HexadecimalToString {
public static void main(String args[]) {
Scanner sc = new Scanner(System.in);
System.out.println("Enter a Hexadecimal value: ");
String str = sc.next();
String result = new String();
char[] charArray = str.toCharArray();
for(int i = 0; i < charArray.length; i=i+2) {
String st = ""+charArray[i]+""+charArray[i+1];
char ch = (char)Integer.parseInt(st, 16);
result = result + ch;
}
System.out.println(result);
}
}