What does error: ArrayList cannot be resolved to a type mean in dr java?
-
By "dr java", are you referring to the tool named DrJava? Don't worry about mentioning that particular tool. Simply mention Java and people will understand what you're talking about. :)Adam Paynter– Adam Paynter2011-03-28 16:07:34 +00:00Commented Mar 28, 2011 at 16:07
-
The OP asked a dupe-like followup question, of sorts, here: stackoverflow.com/questions/5461699/java-errors-in-dr-javaPops– Pops2011-03-28 16:37:04 +00:00Commented Mar 28, 2011 at 16:37
Add a comment
|
2 Answers
You probably need to add the line
import java.util.ArrayList;
To your source file. Post the code to be sure.
9 Comments
Leasha
okay. I did add that to my code but it gave me a lot of different errors
Leasha
Sorry. I am new to java and I really don't know much about it. So I am lost and trying to understand
Jeff Foster
Add some more imports for every flavour of this kind of error that you get, then try to reduce the errors down to a small sample program and post a question with the code. Hopefully people will be able to help!
Leasha
Coding is hard but this is my first experience with it. I have never encountered it before. I am willing to learn that is all that matters. Yes, I may not get it right now but with the right tools and my motivation to keep trying and people helping me I will get there. Not everyone in coding stated out great. They had to learn just as I do.
Leasha
Yeah, times change and things change. Asking for help doesn't mean that I can't do it or that I'm not trying. I don't care if you think I can or can't do it. I know that I can if I keep trying. Anyone can do anything if they set their mind to it. My mind is set and you make it sound like a crime if anyone ever has a question about anything. Not everyone learns the same, so think what you want.
|
It usually means you have forgotten to import the class. Near the top of you java file, put
import java.util.ArrayList;
3 Comments
Leasha
okay. I added that in and got these two errors back: error: the type of the expression must be an array type but it resolved to java.util.ArrayList<java.lang.Integer> and error: length cannot be resolved or is not a field?
Peter Lawrey
ArrayList doesn't have a length attribute (its not an array) You may have intend to use size().
nos
@Leasha take a look at the ArrayList documentation: download.oracle.com/javase/6/docs/api/java/util/ArrayList.html