This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes I'm getting Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "I Watch "I New topic
Author

I'm getting "Cannot find symbol" errors for ArrayList.Count and ArrayList.getElementAt().

John McClellan
Ranch Hand

Joined: Aug 15, 2011
Posts: 35
Hello, I just needed to ask for somebody to take a look at a really small piece of code for me please. I'm compiling Java on the command line in Windows for the first time, and I'm getting a "Cannot find symbol" error for each ArrayList.Count and ArrayList.getElementAt() (the name of the ArrayList is m_items). Here is my code:



I mean, I've imported the necessary package(s) for this to work. I'm running javac from the project's root directory, which has worked with the other classes in there, and I'm telling it javac com\zork\inventory\Inventory.java. Again using javac like that in that directory has worked just fine for other classes in there, so what could I be missing? Thanks!
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19649
    
  18

Welcome to the Ranch!

If you check the Javadoc page of java.util.ArrayList you'll see that it has no property called Count and no method called getElementAt. Count looks more like a C# construct, whereas getElementAt is a method from ListModel. For List (and ArrayList), the methods are size() and get(int).


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
John McClellan
Ranch Hand

Joined: Aug 15, 2011
Posts: 35
Ah, thanks! I thought I remembered using both of them before, and it appears that I was looking at the wrong language's documentation.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: I'm getting "Cannot find symbol" errors for ArrayList.Count and ArrayList.getElementAt().
 
Similar Threads
Access modifiers
noob cp problems in webapp
errors generated when running Ant build file in Eclipse
Help with Package understanding
Error can't find class