16进制字符串转换为10进制数字方法,负数的16进制需要BigInteger封装

String str="aabbcc";

System.out.println(Integer.parseInt(str, 16));

package com.wanju.hope.test;

import java.math.BigInteger;

import org.apache.catalina.util.HexUtils;
import org.hibernate.cfg.Configuration;
import org.hibernate.tool.hbm2ddl.SchemaExport;

public class Test {

	public static void main(String[] args) {

//		System.out.println(Integer.parseInt("FFFF", 16));
		System.out.println(Integer.toHexString(-100)); //输出ffffff9c
		BigInteger bi = new BigInteger("ffffff9c",16);
		System.out.println(bi.intValue());
	}
}


你可能感兴趣的:(Java基础)