jQuery in Action, 3rd edition
The moose likes Beginning Java and the fly likes ArrayList issues adding integers Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "ArrayList issues adding integers" Watch "ArrayList issues adding integers" New topic

ArrayList issues adding integers

Michael Comerford

Joined: Jan 16, 2010
Posts: 13
Hi there,

I'm trying to create an arraylist of arraylists as a data structure to represent demographic data.

I've hit a brick wall already, when I try to add integers to one of my arraylists I get errors.

I'm using Eclipse and this program is for JavaSE 1.6

here's the code...

Eclipse tells me that there is:
Multiple markers at this line
- Syntax error on token(s), misplaced construct(s)
- Syntax error on token "id1", VariableDeclaratorId expected after this

at the lines that start caseid.add

Any help greatly appreciated!


Matthew Brown

Joined: Apr 06, 2010
Posts: 4541

Hi Michael. Welcome to The Ranch!

Your main problem there is that you're trying to add instructions directly to a class, rather than them being in a method. The declarations would work (but probably aren't what you intended - there's no reason for id1-id5 to be member variables). But the add lines have to be in a method (or at least an initialisation block).
Michael Comerford

Joined: Jan 16, 2010
Posts: 13
Doh! Silly mistake, thanks Matthew!

I agree. Here's the link: http://aspose.com/file-tools
subject: ArrayList issues adding integers
It's not a secret anymore!