Error Creating ArrayLists
public class Arrays
{
public static void main (String args[])
{
ArrayList arr = new ArrayList();
int x = 0;
int y = 1;
if (x != arr.length())
{
arr[x] = y;
y = y + 1;
x = x + 1;
}
}
}
The error I get is:
"Cannot resolve symbol class arraylist"
Can someone suggest a fix? Thanks !
Re: Error Creating ArrayLists
Throw an import statement in for java.util.* at the top of the file.
Re: Error Creating ArrayLists
fundean you asked the same question not too long ago.
Re: Error Creating ArrayLists
There's a lot more wrong than just the import statement.
Code:
//import the right crap
import java.util.*;
public class Arrays
{
public static void main (String args[])
{
ArrayList arr = new ArrayList();
int x = 0;
int y = 1;
//fill the arraylist will values
for (int i=0; i<10; i++)
{
arr.add(i + 1);
}
if (x != arr.size())
{
arr.add(x,y);
y = y + 1;
x = x + 1;
}
}
}
Re: Error Creating ArrayLists
The methods and way you had it setup, looked as if you were trying to use an array. The methods for an array are much different than an arraylist.
Re: Error Creating ArrayLists
Yeah he seems to be confusing arrays and ArrayLists. I don't know why since he pretty much used the latter properly in one of his posts not too long ago.
Re: Error Creating ArrayLists
ahh I see. I wonder if he didn't like how you wrote it in 1.5..