I am getting "incompatible types: possibly loss of conversion from long to int" exception in this line: boolean arr[] = new boolean [limit]; I don't understand why this is happening since I am storing the input value in long, how is it getting converted to int?
import java.util.*;
import java.io.*;
public class PrimeSieve
{
public static void main (String args [])
{
//getting the number
Scanner x = new Scanner (System.in);
System.out.println("What is your number?");
long limit = x.nextLong();
long count = 0;
//making all the numbers upto the given number prime
boolean arr[] = new boolean [limit];
for ( long i = 2; i <=Math.sqrt(limit); i++)
{
arr[i] = true;
}