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 282 views
1 answer 236 views
1 answer 178 views
178 views asked Sep 16, 2020 by avibootz
1 answer 143 views
143 views asked Nov 11, 2023 by avibootz
...