Documentation Index
Fetch the complete documentation index at: https://docs.syntblaze.com/llms.txt
Use this file to discover all available pages before exploring further.
Int in Kotlin is a built-in numeric type representing a 32-bit (4-byte) signed two’s complement integer. It is a member of the kotlin package, inherits from the abstract Number class, and implements the Comparable<Int> interface.
Technical Specifications
- Memory Size: 32 bits (4 bytes)
- Minimum Value (
Int.MIN_VALUE): -2,147,483,648 () - Maximum Value (
Int.MAX_VALUE): 2,147,483,647 () - JVM Representation: On the Java Virtual Machine, a non-nullable
Intcompiles directly to the Java primitiveint.
Syntax and Instantiation
Kotlin infers theInt type for any whole number literal that falls within the 32-bit range unless explicitly specified otherwise. Literals can be expressed in decimal, hexadecimal, or binary formats. Octal literals are not supported.
Nullability and Boxing
Kotlin distinguishes between non-nullable (Int) and nullable (Int?) types. This distinction dictates how the compiler allocates memory on the JVM.
Int: Compiled to the unboxed primitiveintto optimize performance and memory.Int?: Compiled to the boxed wrapper classjava.lang.Integer. Boxing also occurs when anIntis used as a generic type argument (e.g.,List<Int>).
===) behaves differently on nullable types compared to structural equality (==). Using === on non-nullable Int types is deprecated as identity equality is meaningless for unboxed primitives.
Explicit Type Conversion
Kotlin does not support implicit widening conversions. AnInt cannot be implicitly assigned to a Long or Double variable. Conversion must be handled explicitly using member functions inherited and overridden from the abstract Number class.
Bitwise Operations
Kotlin does not use standard C-style bitwise operators (e.g.,<<, >>, &, |). Instead, bitwise operations on Int are performed using named functions. Binary bitwise operations are invoked as infix functions, whereas bitwise inversion (inv()) is a unary function that takes no arguments.
Master Kotlin with Deep Grasping Methodology!Learn More





