Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

How can I go about adding an Object to another class Object?  RSS feed

 
Mike Lonsky
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, I am able to pull up the faculty list in the ArrayList, but how can I assign the choice (m) to the Course? Any help would be greatly appreciated. Thank you.
 
Knute Snortum
Sheriff
Posts: 4073
112
Chrome Eclipse IDE Java Postgres Database VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think you are going to have to provide a more detailed question. What is it exactly you are trying to do?

Hi, I am able to pull up the faculty list in the ArrayList,


What's the faculty list? There's a variable called "faculty" but it's not declared or initialized in the method. Is it type List? Is the faculty list "facultyChoice"?

but how can I assign the choice (m) to the Course?


What's the Course? You have an object of type Courses and you are passing m, which is null, to it.
 
Mike Lonsky
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Nvm. I figured it out.
Thank you though.
 
A.J. Côté
Ranch Hand
Posts: 417
Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

We need the FacultyMember source to be able to answer your question.

Also, how are you going to decide which element of the List<FacultyMember> you are going to choose?

Is the FacultyMember the professor?

Anyway, it should go something like this given the list is your FacultyMember list:



 
Campbell Ritchie
Marshal
Posts: 55711
163
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Mike Lonsky wrote:Nvm. I figured it out.
. . .
Please tell us what the solution was. If anybody else searches for the same problem, they will then find the answer.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!