Nick B
5
Q:

java long to int

import static java.lang.Math.toIntExact;

long foo = 10L;
int bar = toIntExact(foo);
2
    public class LongToIntExample2{
      
    	public static void main(String args[]){
          
        	Long l= new Long(10);
        	int i=l.intValue();
        	System.out.println(i);
    	
        }
    }
2
Long l= new Long(i); //first way
Long l2=Long.valueOf(i); //second way
0
// auto-unboxing does not go from Long to int directly, so
Integer i = (int) (long) theLong;
0
long to int
-2

New to Communities?

Join the community