Are you sure you're looking at the right source, and not just a compiled class in your IDE. I have the following:

/**
 * A constant holding the minimum value an {@code int} can
 * have, -2<sup>31</sup>.
 */
public static final int   MIN_VALUE = 0x80000000;

/**
 * A constant holding the maximum value an {@code int} can
 * have, 2<sup>31</sup>-1.
 */
public static final int   MAX_VALUE = 0x7fffffff;

Grep code agrees: http://grepcode.com/file/repository.grepcode.com/java/root/jdk/openjdk/6-b14/java/lang/Integer.java

Answer from sksamuel on Stack Overflow
🌐
Classpath
developer.classpath.org › doc › java › lang › Integer-source.html
Source for java.lang.Integer (GNU Classpath 0.95 Documentation)
48: * 49: * @author Paul Fisher 50: * @author John Keiser 51: * @author Warren Levy 52: * @author Eric Blake (ebb9@email.byu.edu) 53: * @author Tom Tromey (tromey@redhat.com) 54: * @author Andrew John Hughes (gnu_andrew@member.fsf.org) 55: * @since 1.0 56: * @status updated to 1.5 57: */ 58: public final class Integer extends Number implements Comparable<Integer> 59: { 60: /** 61: * Compatible with JDK 1.0.2+. 62: */ 63: private static final long serialVersionUID = 1360826667806852920L; 64: 65: /** 66: * The minimum value an <code>int</code> can represent is -2147483648 (or 67: * -2<sup>31</sup>).
🌐
Openjdk
hg.openjdk.org › jdk8 › jdk8 › jdk › file › 687fd7c7986d › src › share › classes › java › lang › Integer.java
jdk8/jdk8/jdk: 687fd7c7986d src/share/classes/java/lang/Integer.java
March 20, 2018 - The * characters in the string ... exactly as if the argument and the radix 10 were * given as arguments to the {@link #parseInt(java.lang.String, * int)} method....
🌐
Fuseyism
fuseyism.com › classpath › doc › java › lang › Integer-source.html
Source for java.lang.Integer (GNU Classpath 0.99.1-pre Documentation)
48: * 49: * @author Paul Fisher 50: * @author John Keiser 51: * @author Warren Levy 52: * @author Eric Blake (ebb9@email.byu.edu) 53: * @author Tom Tromey (tromey@redhat.com) 54: * @author Andrew John Hughes (gnu_andrew@member.fsf.org) 55: * @author Ian Rogers 56: * @since 1.0 57: * @status updated to 1.5 58: */ 59: public final class Integer extends Number implements Comparable<Integer> 60: { 61: /** 62: * Compatible with JDK 1.0.2+. 63: */ 64: private static final long serialVersionUID = 1360826667806852920L; 65: 66: /** 67: * The minimum value an <code>int</code> can represent is -2147483648 (or 68: * -2<sup>31</sup>).
🌐
GitHub
github.com › openjdk › jdk › blob › master › src › java.base › share › classes › java › lang › Integer.java
jdk/src/java.base/share/classes/java/lang/Integer.java at master · openjdk/jdk
import static java.lang.String.COMPACT_STRINGS; · /** * The {@code Integer} class is the {@linkplain · * java.lang##wrapperClass wrapper class} for values of the primitive · * type {@code int}. An object of type {@code Integer} contains ...
Author   openjdk
🌐
Java Code Geeks
examples.javacodegeeks.com › home › java development › core java
Integer Java Class Example - Java Code Geeks
May 31, 2021 - Running the above code will give the output as below: ... In this article, we learned about the java.lang.Integer Integer Java Class. We looked at the types of ways of constructing the Integer object. We also looked at some of the important static and instance methods and their usages. ... That was an example of the Java Integer Class. Download You can download the full source ...
Find elsewhere
🌐
Oracle
docs.oracle.com › javase › 8 › docs › api › java › lang › Integer.html
Integer (Java Platform SE 8 )
April 21, 2026 - Java™ Platform Standard Ed. 8 ... The Integer class wraps a value of the primitive type int in an object.
🌐
GitHub
github.com › frohoff › jdk8u-jdk › blob › master › src › share › classes › java › lang › Integer.java
jdk8u-jdk/src/share/classes/java/lang/Integer.java at master · frohoff/jdk8u-jdk
import java.lang.annotation.Native; · /** * The {@code Integer} class wraps a value of the primitive type · * {@code int} in an object. An object of type {@code Integer} * contains a single field whose type is {@code int}. * * <p>In ...
Author   frohoff
Top answer
1 of 8
47

Usually this is done like this:

  • init result with 0
  • for each character in string do this
    • result = result * 10
    • get the digit from the character ('0' is 48 ASCII (or 0x30), so just subtract that from the character ASCII code to get the digit)
    • add the digit to the result
  • return result

Edit: This works for any base if you replace 10 with the correct base and adjust the obtaining of the digit from the corresponding character (should work as is for bases lower than 10, but would need a little adjusting for higher bases - like hexadecimal - since letters are separated from numbers by 7 characters).

Edit 2: Char to digit value conversion: characters '0' to '9' have ASCII values 48 to 57 (0x30 to 0x39 in hexa), so in order to convert a character to its digit value a simple subtraction is needed. Usually it's done like this (where ord is the function that gives the ASCII code of the character):

digit = ord(char) - ord('0')

For higher number bases the letters are used as 'digits' (A-F in hexa), but letters start from 65 (0x41 hexa) which means there's a gap that we have to account for:

digit = ord(char) - ord('0')
if digit > 9 then digit -= 7

Example: 'B' is 66, so ord('B') - ord('0') = 18. Since 18 is larger than 9 we subtract 7 and the end result will be 11 - the value of the 'digit' B.

One more thing to note here - this works only for uppercase letters, so the number must be first converted to uppercase.

2 of 8
28

The source code of the Java API is freely available. Here's the parseInt() method. It's rather long because it has to handle a lot of exceptional and corner cases.

public static int parseInt(String s, int radix) throws NumberFormatException {
    if (s == null) {
        throw new NumberFormatException("null");
    }

    if (radix < Character.MIN_RADIX) {
        throw new NumberFormatException("radix " + radix +
            " less than Character.MIN_RADIX");
    }

    if (radix > Character.MAX_RADIX) {
        throw new NumberFormatException("radix " + radix +
            " greater than Character.MAX_RADIX");
    }

    int result = 0;
    boolean negative = false;
    int i = 0, max = s.length();
    int limit;
    int multmin;
    int digit;

    if (max > 0) {
        if (s.charAt(0) == '-') {
            negative = true;
            limit = Integer.MIN_VALUE;
            i++;
        } else {
            limit = -Integer.MAX_VALUE;
        }
        multmin = limit / radix;
        if (i < max) {
            digit = Character.digit(s.charAt(i++), radix);
            if (digit < 0) {
                throw NumberFormatException.forInputString(s);
            } else {
                result = -digit;
            }
        }
        while (i < max) {
            // Accumulating negatively avoids surprises near MAX_VALUE
            digit = Character.digit(s.charAt(i++), radix);
            if (digit < 0) {
                throw NumberFormatException.forInputString(s);
            }
            if (result < multmin) {
                throw NumberFormatException.forInputString(s);
            }
            result *= radix;
            if (result < limit + digit) {
                throw NumberFormatException.forInputString(s);
            }
            result -= digit;
        }
    } else {
        throw NumberFormatException.forInputString(s);
    }
    if (negative) {
        if (i > 1) {
            return result;
        } else { /* Only got "-" */
            throw NumberFormatException.forInputString(s);
        }
    } else {
        return -result;
    }
}
🌐
GitHub
github.com › openjdk-mirror › jdk7u-jdk › blob › master › src › share › classes › java › lang › Integer.java
jdk7u-jdk/src/share/classes/java/lang/Integer.java at master · openjdk-mirror/jdk7u-jdk
import java.util.Properties; · /** * The {@code Integer} class wraps a value of the primitive type · * {@code int} in an object. An object of type {@code Integer} * contains a single field whose type is {@code int}. * * <p>In addition, ...
Author   openjdk-mirror
🌐
Classpath
developer.classpath.org › doc › java › lang › Number-source.html
Source for java.lang.Number (GNU Classpath 0.95 Documentation)
Source for java.lang.Number · 1: /* Number.java =- abstract superclass of numeric objects 2: Copyright (C) 1998, 2001, 2002, 2005 Free Software Foundation, Inc. 3: 4: This file is part of GNU Classpath. 5: 6: GNU Classpath is free software; you can redistribute it and/or modify 7: it under ...
🌐
Sololearn
sololearn.com › en › Discuss › 1710145 › i-need-source-code-to-read-an-integer-in-java
I need source code to read an integer in java | Sololearn: Learn to code for FREE!
March 3, 2019 - int integer = scanner.nextInt(); or int integer = Integer.parseInt(scanner.nextLine()); 3rd Mar 2019, 1:45 PM · Salif Mehmed 🇹🇷🇧🇬 · + 6 · https://code.sololearn.com/cHo98F3aWYK3/?ref=app · 3rd Mar 2019, 6:09 AM · Rowsej · + ...
🌐
GitHub
github.com › openjdk › jdk13 › blob › master › src › java.base › share › classes › java › lang › Integer.java
jdk13/src/java.base/share/classes/java/lang/Integer.java at master · openjdk/jdk13
import static java.lang.String.UTF16; · /** * The {@code Integer} class wraps a value of the primitive type · * {@code int} in an object. An object of type {@code Integer} * contains a single field whose type is {@code int}. * * <p>In ...
Author   openjdk
🌐
Scientech Easy
scientecheasy.com › home › blog › java integer class
Java Integer Class - Scientech Easy
February 3, 2025 - Learn Java Integer class with example program, Integer class declaration, field constants, constructors, methods defined by Integer class
🌐
Oracle
docs.oracle.com › javase › 7 › docs › api › java › lang › Integer.html
Integer (Java Platform SE 7 )
Decodes a String into an Integer. Accepts decimal, hexadecimal, and octal numbers given by the following grammar: ... + DecimalNumeral, HexDigits, and OctalDigits are as defined in section 3.10.1 of The Java™ Language Specification, except that underscores are not accepted between digits.
🌐
Programmersought
programmersought.com › article › 23234211718
Integer of Java source code - Programmer Sought
table of Contents Key points: Source code: Source note: Key points: Determine if the first letter is less than zero, "+" "-" Less than zero may be "+" "-&quot... Prerequisite knowledge: Java's automatic boxing and unboxing: When auto-boxing, the compiler calls **valueOf (not constructor)** to convert the original type value to an object, and when unboxing, the... It can be seen from the class definition that Integer can not be inherited, inherits the Number class, and implements Comparable.