hex - convert a hexadecimal into a decimal via string convert in java -
i want convert string hexadecimal decimal value used integer.decode value hast written user.
package hexa; import java.util.scanner; public class hexa { public static void main(string[] args) { scanner in = new scanner(system.in); string str1; system.out.print("ingrese el hexadecimal= "); str1 = in.nextline(); system.out.println("from hex: " + integer.decode("#str1")); } }
use overloaded integer.parseint
method takes second parameter radix:
integer.parseint(str1, 16);
Comments
Post a Comment