#APCS Question

18 messages · Page 1 of 1 (latest)

fringe needle
#

can someone explain what the System.out.print(students.set(k, "Alex") + " "); does? how can you put the students.set in a print statement and why doesnt it set them all to alex ? (the answer is C)

small etherBOT
#

This post has been reserved for your question.

Hey @fringe needle! Please use /close or the Close Post button above when you're finished. Please remember to follow the help guidelines. This post will be automatically closed after 300 minutes of inactivity.

TIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here.

barren nest
#

that's why in first loop it returns names of students (they are strings, so are ok for print method)

#

but in second loop it returns only Alex

#

because they all were set to Alex

fringe needle
#

Wait set method returns stuff???

barren nest
#

that's what I told

#

and sent the link of docs

#

Returns:
the element previously at the specified position

#

and since it's list of String elements

#

you can print it

fringe needle
#

Ohh ok thank you

small etherBOT
# fringe needle Ohh ok thank you

If you are finished with your post, please close it.
If you are not, please ignore this message.
Note that you will not be able to send further messages here after this post have been closed but you will be able to create new posts.

barren nest
#

np 😉

barren nest