Convert int to Long in Java

1 min read
Date: 2023-12-10
This Java tutorial explains how to convert integers (int
) to long integers (long
). It details several methods: autoboxing (automatic conversion between primitives and wrapper classes), Long.valueOf()
(creating a Long
object from a primitive or string), and Long.parseLong()
(parsing a string into a long
). While new Long()
is possible, Long.valueOf()
is recommended for better performance. The article emphasizes the importance of understanding the differences between int
and long
regarding data range and usage.
Read more: https://examples.javacodegeeks.com/java-int-to-long-conversion/
0
Subscribe to my newsletter
Read articles from Yatin B. directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by
