我有一个应该充满整数的数组列表的数组列表,但是当我尝试编译程序时,我收到一条错误消息,指出由于操作数类型 Object 和 Int 不兼容,它无法向其中添加数字。任何帮助,将不胜感激!
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
public class main{
public static void main(String[] args){
int ntt = 20;
ArrayList<Integer> Factors = new ArrayList<Integer>();
ArrayList<List> FactorsList = new ArrayList<List>();
ArrayList<Integer> Occurences = new ArrayList<Integer>();
System.out.println("Smallest Multiple of Numbers 1-20\n---------------------------------\n\nSearching...");
for(int i = 2; i <= ntt; i++){
FactorsList.add(isPrime(i));
}
for(int i = 2; i <= ntt; i++)
for(int j = 0; j < FactorsList.size(); j++)
for(int k = 0; k < FactorsList.get(j).size();k++){
if(FactorsList.get(j).get(k)==i){
Occurences.set(i, i+1);
}
}
}
static List<Long> isPrime(long num){
List<Long> ar = new ArrayList<Long>();
for(long count=2;count<=num;count++){
while(num%count == 0){
ar.add(count);
num /= count;
}
}
return ar;
}
}