It is an arraylist of arraylists of integers. I'm still running into an issue though when I try to compile. The command prompt says "incompatible types." I know for sure that all the function calls are correct (i.e.: .getStart(), .getEnd(), etc. - I wrote those classes and have tested them thoroughly.) Btw, "permOfEdges" is: ArrayList <ArrayList<Edge>> (Edge being a class I wrote.)
Since it's: visited.get(-).get(-), it says the second .get(-) should be a variable not a value. I'm confused on what it means since it's an arraylist of arraylists.
Code for arraylist of arraylists:
ArrayList<ArrayList<Integer>> visited = new ArrayList<ArrayList<Integer>>();
for(int i = 1; i < permOfEdges.size(); i++)
{
for(int j = 0; j < permOfEdges.get(i).size(); j++)
{
visited.get(i).get(j) = 0; // this is to initialize the entire thing to only contain zeros
}
}
for(int i = 1; i < permOfEdges.size(); i++)
{
for(Edge point: permOfEdges.get(i))
{
if((visited.get(point.getEnd()).get(point.getStart()) == 0) && visited.get(point.getStart().get(point.getEnd()) == 0)) // means NOT visited yet
{
writer.println(point.getStart() + " " + point.getEnd() + " " + point.getDistance() + " " + point.getPrice());
}
visited.get(point.getStart()).get(point.getEnd()) = 1;
visited.get(point.getEnd()).get(point.getStart()) = 1;
}
}
writer.close();
The error reads: 1. unexpected types: visited.get(i).get*(j) = 0 (* = where the ^ was in the command prompt) required: variable found: value
- int cannot be dereferenced if((visited.get(point.getEnd()).get*(point.getStart()) == 0) &&...)
- and 4. both of these errors are the same as the first one except it focuses on the two lines where I assign visited.get(..).get(..) = 1
Any help would be much appreciated! Thank you!