0 votes
1.4k views
in Java by
How to convert int to long in java? Please provide an example.

1 Answer

0 votes
by
There are various way to convert int to long:

package com;

public class IntToLongConversion {

    /**
     * @param args
     */
    public static void main(String[] args) {
        int intNum = 100;
        long lVal = Long.parseLong(intNum + "");
        System.out.println("int val: " + intNum + " long val: " + lVal);
        Long lVal1 = Long.valueOf(intNum);
        System.out.println("int val: " + intNum + " Long val: " + lVal1);
    }

}

Output:
int val: 100 long val: 100
int val: 100 Long val: 100

Share:- Whatsapp Facebook Facebook


Welcome to Developerhelpway Q&A, where you can ask questions and receive answers from other members of the community.

Categories

...