How to convert from int to long in Java

2 Answers

0 votes
public class MyClass {
    public static void main(String args[]) {
        int n = 940384;
        
        long l = (long)n;

        System.out.println(l);
    }
}




/*
run:

940384

*/

 



answered Nov 8, 2023 by avibootz
0 votes
public class MyClass {
    public static void main(String args[]) {
        int n = 940384;
        
        long l = Long.valueOf(n);

        System.out.println(l);
    }
}




/*
run:

940384

*/

 



answered Nov 8, 2023 by avibootz

Related questions

2 answers 260 views
1 answer 227 views
1 answer 171 views
171 views asked Sep 16, 2020 by avibootz
1 answer 136 views
136 views asked Nov 11, 2023 by avibootz
...