List <BigInteger> valaArr = new ArrayList <BigInteger>();
Scanner value = new Scanner(System.in);
System.out.print("Enter number to test for prime: ");
BigInteger n = value.nextBigInteger();
for(BigInteger i = BigInteger.valueOf(1); i.compareTo(n) = -1; i = i.add(BigInteger.valueOf(1)))
{
valaArr.add(i);
}
Apparently my i.compareTo(n) is giving me a unexpected type, variable required value found. Any idea why is it happening even though my i and n are variables?
You can try this solution
for(BigInteger i = BigInteger.valueOf(1); i.compareTo(n) <0; i = i.add(BigInteger.valueOf(1)))
{
valaArr.add(i);
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.