Check out example codes for "class java.lang.Integer cannot be cast to class java.lang.Long (java.lang.Integer and java.lang.Long are in module java.base of loader 'bootstrap')". It will help you in understanding the concepts better.

Code Example 1

// on my case, instead of casting I did:

Long variable = Long.valueOf(variable.get("Attribute").toString());

Learn ReactJs, React Native from akashmittal.com