CONVERT DECIMAL INTEGER TO HEXADECIMAL
NUMBER EXAMPLE
import java.io.*;
import java.lang.*;
public class DecimalToHexadecimal{
public static void main(String[] args) throws IOException{
BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
System.out.println("Enter the decimal value:");
String hex = bf.readLine();
int i = Integer.parseInt(hex);
String hex1 = Integer.toHexString(i);
System.out.println("Hexa decimal: " + hex1);
}
}
run:
Enter the decimal value:
16
Hexa decimal: 10
the code was very useful
ReplyDelete