I wish to enter one int and another long ex: 1 and 1000000000, and now I wish to create an array of size 1000000000. And then at each index of arra
I think you have some misconception about typecasting here. In Java down casting is allowed as already mentioned you can down cast it to integer
arr = new long[(int)(y+1)];
But here the main problem is that array allocation should takes integer value so that the same number of homogeneous space can be allocated. If you want more space than an integer range then you should use ArrayList which is dynamically grow-able array because if we give that much liability to a user to declare a large amount array memory then our system may run out of the memory as array is a static memory allocation data structure. The same stands true for
arr[j]=4;
It should be:
arr[(int)j]=4;