• Post Reply Bookmark Topic Watch Topic
  • New Topic

Trying to set an ArrayList within an object class  RSS feed

 
Bob Raupach
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, I'm trying to teach myself java, and am stuck on a concept that I wish to learn.

I'm trying to have a new object class (GroupX) that has several attributes, including an ArrayList that may contain one or more other objects (of type CyclistX).  Within my test code, when attempting to invoke GroupX's SetGroup method, I receive the following message:

   The method setGroup(List<CyclistX>) is undefined for the type List<GroupX>


Overall, what I want to do is to simulate a bicycle race with many cyclists, all having various attributes. Occasionally, groups of cyclists will form, and the groups themselves will have a number of different attributes, including an ArrayList of cyclists. I want to manipulate the cyclists from the main part of the program and use setGroup(...) and getGroup() methods to update the groups. (...and of course, I can't get this to work as it's presently coded).


Here is my code:



Any help would be appreciated.
Bob R        

 
Carey Brown
Saloon Keeper
Posts: 3310
46
Eclipse IDE Firefox Browser Java MySQL Database VI Editor Windows
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"teams" is a List. You need an individual team in order to call setGroup(). Example:

 
Bob Raupach
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Wow, fantastic - thank you very much!!  It worked, and I am learning
 
Campbell Ritchie
Marshal
Posts: 56529
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
...and welcome to the Ranch
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!