Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p><code>int</code> is a primitive type. Variables of type <code>int</code> store the actual binary value for the integer you want to represent. <code>int.parseInt("1")</code> doesn't make sense because <code>int</code> is <em>not</em> a class and therefore doesn't have any methods.</p> <p><code>Integer</code> is a class, no different from any other in the Java language. Variables of type <code>Integer</code> store <em>references</em> to <code>Integer</code> objects, just as with any other reference (object) type. <code>Integer.parseInt("1")</code> is a call to the static method <code>parseInt</code> from class <code>Integer</code> (note that this method actually returns an <code>int</code> and not an <code>Integer</code>).</p> <p>To be more specific, <code>Integer</code> is a class with a single field of type <code>int</code>. This class is used where you need an <code>int</code> to be treated like any other object, such as in generic types or situations where you need nullability.</p> <p>Note that every primitive type in Java has an equivalent <em>wrapper</em> class: </p> <ul> <li><code>byte</code> has <code>Byte</code></li> <li><code>short</code> has <code>Short</code></li> <li><code>int</code> has <code>Integer</code></li> <li><code>long</code> has <code>Long</code></li> <li><code>boolean</code> has <code>Boolean</code></li> <li><code>char</code> has <code>Character</code></li> <li><code>float</code> has <code>Float</code></li> <li><code>double</code> has <code>Double</code></li> </ul> <p>Wrapper classes inherit from Object class, and primitive don't. So it can be used in collections with Object reference or with Generics.</p> <p>Since java 5 we have autoboxing, and the conversion between primitive and wrapper class is done automatically. Beware, however, as this can introduce subtle bugs and performance problems; being explicit about conversions never hurts.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload