Main Tutorials

Java – Convert Integer to Long

In Java, we can use Long.valueOf() to convert an Integer to a Long

TestInteger.java

package com.mkyong.example;

public class TestInteger {

    public static void main(String[] args) {

        Integer num = 1;

        System.out.println(num);            // 1

        Long numInLong = Long.valueOf(num);

        System.out.println(numInLong);      // 1

    }
}

References

About Author

author image
Founder of Mkyong.com, love Java and open source stuff. Follow him on Twitter. If you like my tutorials, consider make a donation to these charities.

Comments

Subscribe
Notify of
1 Comment
Most Voted
Newest Oldest
Inline Feedbacks
View all comments
Coder
2 years ago

Its not working.