Here you can find the source of toIntExact(long value)
public static int toIntExact(long value)
//package com.java2s; //License from project: Open Source License public class Main { public static int toIntExact(long value) { if ((int) value != value) { throw new ArithmeticException("integer overflow"); }//from w w w. j a v a 2 s.c o m return (int) value; } }