We often use the method of Integer.Valueof (String Str), if the string format is wrong, this method will throw a system exception NumberFormatexception Here we want to analyze this method, where Byte, Short also calls the method in INGETER. The definition in the Integer class is as follows: public static integer valueof (String s) throws numberXception {return new integer (Parseint (s, 10));} This is called because of the INT type returned by the PARSEINT method, which calls a constructor generation A new INTEGER instance. He cares about the PARSEINT method. The method code is as follows: public static int parseint (String s, int Radix) throws Numberformatexception {if (s == null) {throw new numberXception ("null);" null "); } if (radix digit) {throw NumberFormatException.forInputString (s); abnormal 2} result - = digit;}} else {throw NumberFormatException.forInputString (s);} if (negative) {if (i> 1) {return result;} else { / * ONLY GOT "-" * / throw number {returnception.forinputString (s);}} else {return-result;}} is clear, the second parameter of this method is a base (most commonly used 10), and there are ten Six mechanism, octal, etc.). If the string is an empty pointer, do not throw an exception. If the foundation is less than 2 or more than 36, throw an exception (this general will not appear, because we use the most, it is decimal. If it is an empty string, it also throws an exception, which is the case of max = 0. Let's pay attention to the following conversion process: here use the static method DIGIT in Character, this method is more complicated, here Function: For a given base, if it is a legal character (can be converted to a number), return the digital value, otherwise returns -1. For example, DIGIT ('3', 10) returns 3, DIGIT ('A', 10) Return -1. This program looks very simple, in fact, it is really not easy to understand, here to explain the meaning of several local variables: Result: Record return value NEGATIVE: Symbol flag i: String position S: String length LIMIT: Bounder Multmin: is also a boundary DIGIT: The number of current characters is represented by first character is '-', set symbol markers NEGATIVE and limit value limit. Notice that LIMIT must be a negative value. Process the highest bit Here, RESULT saves a negative value so that the positive and negative number is unified. The key is this while loop, the first IF does not explain, it is definitely because illegal characters. The meaning of the second IF statement: If Result What is less than Multmin? Is it possible? Is it possible to overflow? Assumption will not overflow, that is, the result must be> = limit.Result less than Multmin, Result should be multimin-1, there is result = result * radix = ( Multmin-1) * radix = MULTMIN * RADIX-RADIX This value is affirmative Less than Limit, where multmin = limited / radix, pay attention to the negative number. So if the result is less than Multmin, then it will overflow. If there is no judgment here, the overflow is troublesome, positive number will change the number. The meaning of the third IF statement: It is certainly no overflow before this statement, but it is possible to add the last digit to overflow, so this judgment is also necessary. The following is better understood, Else is empty String "". "If it is negative, it is necessary to see if the length is 1, just a '-' situation. If it is a positive number, return the opposite number. There are many places there in many places, as long as I understand that the procedure knows this abnormality is thrown, here considering overflow exception: exception 1 and exceptions 2.inger.max_value = 2147483647 The following two statements are thrown out of different places. Ingteer.Valueof "2147483648"); this is thrown in an exception 2; this is thrown at an exception 1. This is a simple analysis of String to incorpore, in fact, the entire INGETER class is mainly This method, Byte and Short are calling this method. Take a look at byte: public static byte parsebyte (string s, int radix) Numberformatexception {Int i = integer.parseint (S, RADIX); if (i < Min_value || i>