Telegram Group & Telegram Channel
🚀 Java API Tip — Integer.valueOf() и кеширование 🚀

Знаешь ли ты, что Integer.valueOf(int) не всегда создаёт новый объект?

📦 Значения в диапазоне от -128 до 127 кэшируются!
Это значит, что:


Integer a = Integer.valueOf(100);
Integer b = Integer.valueOf(100);
System.out.println(a == b); // 👉 true (один и тот же объект)


Но:


Integer x = Integer.valueOf(200);
Integer y = Integer.valueOf(200);
System.out.println(x == y); // 👉 false (два разных объекта)


🔍 Почему так?

Чтобы повысить производительность и сэкономить память, Java автоматически кеширует часто используемые значения.

🛠 Кстати, ты можешь изменить границу кеша через JVM-опцию:


-XX:AutoBoxCacheMax=512


📌 Полезно, если у тебя в системе часто используются числа вне стандартного диапазона.

#Java #Performance #JVM #DevTips

@javatg



tg-me.com/javatg/1867
Create:
Last Update:

🚀 Java API Tip — Integer.valueOf() и кеширование 🚀

Знаешь ли ты, что Integer.valueOf(int) не всегда создаёт новый объект?

📦 Значения в диапазоне от -128 до 127 кэшируются!
Это значит, что:


Integer a = Integer.valueOf(100);
Integer b = Integer.valueOf(100);
System.out.println(a == b); // 👉 true (один и тот же объект)


Но:


Integer x = Integer.valueOf(200);
Integer y = Integer.valueOf(200);
System.out.println(x == y); // 👉 false (два разных объекта)


🔍 Почему так?

Чтобы повысить производительность и сэкономить память, Java автоматически кеширует часто используемые значения.

🛠 Кстати, ты можешь изменить границу кеша через JVM-опцию:


-XX:AutoBoxCacheMax=512


📌 Полезно, если у тебя в системе часто используются числа вне стандартного диапазона.

#Java #Performance #JVM #DevTips

@javatg

BY Java


Warning: Undefined variable $i in /var/www/tg-me/post.php on line 283

Share with your friend now:
tg-me.com/javatg/1867

View MORE
Open in Telegram


Java Telegram | DID YOU KNOW?

Date: |

The SSE was the first modern stock exchange to open in China, with trading commencing in 1990. It has now grown to become the largest stock exchange in Asia and the third-largest in the world by market capitalization, which stood at RMB 50.6 trillion (US$7.8 trillion) as of September 2021. Stocks (both A-shares and B-shares), bonds, funds, and derivatives are traded on the exchange. The SEE has two trading boards, the Main Board and the Science and Technology Innovation Board, the latter more commonly known as the STAR Market. The Main Board mainly hosts large, well-established Chinese companies and lists both A-shares and B-shares.

Telegram hopes to raise $1bn with a convertible bond private placement

The super secure UAE-based Telegram messenger service, developed by Russian-born software icon Pavel Durov, is looking to raise $1bn through a bond placement to a limited number of investors from Russia, Europe, Asia and the Middle East, the Kommersant daily reported citing unnamed sources on February 18, 2021.The issue reportedly comprises exchange bonds that could be converted into equity in the messaging service that is currently 100% owned by Durov and his brother Nikolai.Kommersant reports that the price of the conversion would be at a 10% discount to a potential IPO should it happen within five years.The minimum bond placement is said to be set at $50mn, but could be lowered to $10mn. Five-year bonds could carry an annual coupon of 7-8%.

Java from es


Telegram Java
FROM USA