This week's book giveaway is in the Artificial Intelligence forum.
We're giving away four copies of Pragmatic AI and have Noah Gift on-line!
See this thread for details.
Win a copy of Pragmatic AI this week in the Artificial Intelligence forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
Sheriffs:
  • Paul Clapham
  • Junilu Lacar
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Ganesh Patekar
  • Tim Moores
  • Pete Letkeman
  • Stephan van Hulst
Bartenders:
  • Carey Brown
  • Tim Holloway
  • Joe Ess

ArrayList issues adding integers  RSS feed

 
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

 
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!

 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!