Win a copy of Cloud Native PatternsE this week in the Cloud forum
or Natural Language Processing in the AI/ML 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:
  • Campbell Ritchie
  • Devaka Cooray
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Paul Clapham
  • Knute Snortum
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Ron McLeod
  • Piet Souris
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Frits Walraven
  • Ganesh Patekar

stuck with this array

 
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
coded this but for somereason it wont let me add a string into it, or do i need a different type of array?


[ November 28, 2004: Message edited by: Cougar Vis ]
 
Ranch Hand
Posts: 1272
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


You have to match a method signature:
public boolean add(Object o)
or
public void add(int index, Object element)

try this:
exits.add( "north" );
exits.add( "west" );

By the way,what are you doing with the formal parameter "theExits"?
 
Bartender
Posts: 1840
Eclipse IDE Ruby Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
the add method takes 1 parameter (well, there are versions that take ore than one, but none that takes two strings....)

What you need to do is break up the adding of things into the list into two separate commands:


Also, I would just declare the exits to be a List; this hids that fact that it is an array list and lets you replace it with any type of list later one (like a LinkedList). Not that that is likely to happen here, but it is a good habit to get into.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!