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: |

How to Use Bitcoin?

n the U.S. people generally use Bitcoin as an alternative investment, helping diversify a portfolio apart from stocks and bonds. You can also use Bitcoin to make purchases, but the number of vendors that accept the cryptocurrency is still limited. Big companies that accept Bitcoin include Overstock, AT&T and Twitch. You may also find that some small local retailers or certain websites take Bitcoin, but you’ll have to do some digging. That said, PayPal has announced that it will enable cryptocurrency as a funding source for purchases this year, financing purchases by automatically converting crypto holdings to fiat currency for users. “They have 346 million users and they’re connected to 26 million merchants,” says Spencer Montgomery, founder of Uinta Crypto Consulting. “It’s huge.”

Telegram has exploded as a hub for cybercriminals looking to buy, sell and share stolen data and hacking tools, new research shows, as the messaging app emerges as an alternative to the dark web.An investigation by cyber intelligence group Cyberint, together with the Financial Times, found a ballooning network of hackers sharing data leaks on the popular messaging platform, sometimes in channels with tens of thousands of subscribers, lured by its ease of use and light-touch moderation.Java from ar


Telegram Java
FROM USA