Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
intaとintbの16進値の前に接頭辞「0x」が付いていることを確認してください。文字列からもっと作りたいです。IntegerからparseIntを使用しようとしましたが、NumberFormatExceptionが発生します。誰か助けてもらえますか?
int a = 0xA; int b = 0x4; String f = "0xF"; int d = Integer.parseInt(f, 16);
「intd=0xF」が欲しい
これはどう?
String f = "0xF"; int d = Integer.parseInt(f.substring(2), 16); System.out.println(d);
出力:
15
試す:
Integer.decode("0x64");
同様の質問が SO で以前に尋ねられました。詳細については、次のリンクを参照してください。
Java での整数文字列の解析