I'm getting a compile error that says "incompatible types" in my for loop below. My array is 2-d array of type int and each element, "i", is delclared as an int as well so I really don't see why I'm getting this error.
import java.util.ArrayList;
public class Square
{
ArrayList <Integer> numbers;
int[][] squares;
private int row;
private int col;
public Square()
{
numbers = new ArrayList <Integer>();
squares = new int[row][col];
}
public void add(int i)
{
numbers.add(i);
}
public boolean isSquare()
{
double squareSize = Math.sqrt(numbers.size());
if(squareSize % 1 == 0)
{
return true;
}
else if(squareSize % 1 != 0)
{
return false;
}
}
public boolean isUnique()
{
for(int i: squares)//THIS IS WHERE I AM GETTING AN COMPILE ERROR
{
int occurences = Collections.frequency(squares, i);
if(occurrences > 1)
{
return false;
}
else
{
return true;
}
}
}