This week's book giveaway is in the Other Languages forum.
We're giving away four copies of Functional Reactive Programming and have Stephen Blackheath and Anthony Jones on-line!
See this thread for details.
Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

ArrayList issues adding integers

 
Michael Comerford
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
token

at the lines that start caseid.add

Any help greatly appreciated!

Michael

 
Matthew Brown
Bartender
Posts: 4568
9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Doh! Silly mistake, thanks Matthew!

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic