JAVA_IIBRARY Telegram 1459
Java API Tip

Безопасное приведение long к int

Используй Math.toIntExact() — этот метод возвращает значение long, но выбрасывает ArithmeticException, если оно не помещается в int

Без него преобразование произойдёт молча — и ты можешь получить некорректный результат без всяких ошибок.

Используй toIntExact, когда важно контролировать переполнение

👉 Java Portal
Please open Telegram to view this post
VIEW IN TELEGRAM



tgoop.com/Java_Iibrary/1459
Create:
Last Update:

Java API Tip

Безопасное приведение long к int

Используй Math.toIntExact() — этот метод возвращает значение long, но выбрасывает ArithmeticException, если оно не помещается в int

Без него преобразование произойдёт молча — и ты можешь получить некорректный результат без всяких ошибок.

Используй toIntExact, когда важно контролировать переполнение

👉 Java Portal

BY Java Portal | Программирование




Share with your friend now:
tgoop.com/Java_Iibrary/1459

View MORE
Open in Telegram


Telegram News

Date: |

Public channels are public to the internet, regardless of whether or not they are subscribed. A public channel is displayed in search results and has a short address (link). The group’s featured image is of a Pepe frog yelling, often referred to as the “REEEEEEE” meme. Pepe the Frog was created back in 2005 by Matt Furie and has since become an internet symbol for meme culture and “degen” culture. The visual aspect of channels is very critical. In fact, design is the first thing that a potential subscriber pays attention to, even though unconsciously. How to Create a Private or Public Channel on Telegram? How to create a business channel on Telegram? (Tutorial)
from us


Telegram Java Portal | Программирование
FROM American