|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?注册
x
发信人: bitilittlebe (浪漫苦瓜), 信区: Java
标 题: Re: 请问怎么把String类型转换成16进制的整数
发信站: BBS 水木清华站 (Thu Jan 16 17:26:18 2003)
public static void main(String args[]){
String x = "0x300C8";
int y = Integer.decode(x).intValue();
System.out.println(y);
}
这样转化出来的是
196808
Press any key to continue...
是你要的结果么?
【 在 dolathy 的大作中提到: 】
: String x = "0x300C8";
: int y = Interger.valueof(x).intvalue()
: 会报错,应该怎么转换呢?
: 谢谢!
--
※ 来源:·BBS 水木清华站 smth.org·[FROM: 203.207.68.50]
发信人: hqp263 (hqp263), 信区: Java
标 题: Re: 请问怎么把String类型转换成16进制的整数
发信站: BBS 水木清华站 (Fri Jan 17 22:53:23 2003)
或者也可以用toString(int/long i, int radix)这个函数更灵活
【 在 XML. 的大作中提到: 】
: 转信站: SMTH!maily.cic.tsinghua.edu.cn!news.neu.edu.cn!SJTU
: Integer.toHexString(int x);
: 【 在 mousewu@smth.org (i can do) 的大作中提到: 】
: : 如果是int x=16
: : 要把它打印出16进制的形式,即"0x0010"
: : 怎么做 |
|