# The question for basic type

**URL:** <https://discuss.kotlinlang.org/t/the-question-for-basic-type/2217>\
**Category:** Support\
**Created:** [January 15, 2017, 10:59am UTC](https://discuss.kotlinlang.org/t/the-question-for-basic-type/2217 "2017-01-15T10:59:23Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![KrChou](https://avatars.discourse-cdn.com/v4/letter/k/49beb7/32.png) [@KrChou](https://discuss.kotlinlang.org/u/KrChou)\
**Post date:** [January 15, 2017, 10:59am UTC](https://discuss.kotlinlang.org/t/the-question-for-basic-type/2217/1 "2017-01-15T10:59:24Z")

</div>

In the reference.I saw this code.  
val a: Int = 10000  
val boxedA: Int? = a  
val anotherBoxedA: Int? = a  
print(boxedA === anotherBoxedA) // !!!Prints ‘false’!!!

When I run this code in my intellij idea. I get the result ‘false’.  
But when I modify the code like below.  
val a: Int = 1  
val boxedA: Int? = a  
val anotherBoxedA: Int? = a  
print(boxedA === anotherBoxedA)  
I got the result ‘true’.

Who can tell me why? Or is this a bug?

---

<div class="post-metadata">

**Author:** ![fvasco](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.kotlinlang.org/fvasco/32/1961_2.png) [@fvasco](https://discuss.kotlinlang.org/u/fvasco)\
**Post date:** [January 15, 2017, 11:14am UTC](https://discuss.kotlinlang.org/t/the-question-for-basic-type/2217/2 "2017-01-15T11:14:33Z")

</div>

This is a Java trick, you response is here:

[http://grepcode.com/file/repository.grepcode.com/java/root/jdk/openjdk/6-b14/java/lang/Integer.java#Integer.valueOf(int)](http://grepcode.com/file/repository.grepcode.com/java/root/jdk/openjdk/6-b14/java/lang/Integer.java#Integer.valueOf%28int%29)

Some int values (-128…127) are cached, others are instantiated every time.

This behaviour is unspecified and subject to change, so use “==” instead “===”.

---

<div class="post-metadata">

**Author:** ![KrChou](https://avatars.discourse-cdn.com/v4/letter/k/49beb7/32.png) [@KrChou](https://discuss.kotlinlang.org/u/KrChou)\
**Post date:** [January 15, 2017, 12:24pm UTC](https://discuss.kotlinlang.org/t/the-question-for-basic-type/2217/3 "2017-01-15T12:24:38Z")

</div>

> [@fvasco](#):
>
> subject

Thank you very much.  
I will memorize this.
