¾ÍÊÇÈçºÎ°Ñ String cardId="D42BBF2300A300"; ת³É long l = 0XD42BBF2300A300l; Integer.parseInt(String str)Õâ¸öº¯ÊýÖªµÀÂ𣿠LongµÄ¶ÔÓ¦µÄ ÖªµÀ°¡¡£¡£²»¹ý±¨´í¡£¡£¡£¡£¡£¡£¡£ Exception in thread "main" java.lang.NumberFormatException: For input string: "D42BBF2300A300l" at java.lang.NumberFormatException.forInputString(NumberFormatException.java:48) at java.lang.Long.parseLong(Long.java:403) at java.lang.Long.parseLong(Long.java:461) at serialP.Main.main(Main.java:77) Java Result: 1
Java code:
public class ParseLong {
public static void main(String[] args) {
String cardId="D42BBF2300A300"; Long n = Long.parseLong(cardId, 16); System.out.println(Long.toHexString(n)); }
}
Java code: public static void main(String[] argv){ String cardId="D42BBF2300A300"; Long l = Long.parseLong(cardId,16); System.out.println(l); System.out.println(Long.toString(l,16)); }
²»ÖªµÀÊÇʲôÔÒò£¬ÎÒ¸ÃÈçºÎ´¦Àí£¬Çë´óϺÃÇÖ¸½ÌÁË£¬Ð¡µÜÔÚ´Ëл¹ý¡£¡£¡£¡£ ´íÎóÐÅÏ¢ÈçÏ£º The program being debugged was signaled while in a function called from GDB. GDB has restored the context t ......
1 public class BirthDate { 2 private int day; 3 private int month; 4 private int year; 5 6 public BirthDate (){} 7 8 public BirthDate (int d,int m,int y){ 9 day = d; ......