Ask your own question, for FREE!
Computer Science 17 Online
OpenStudy (mimi_x3):

I have a linkedlist in java

OpenStudy (mimi_x3):

in one of the last sub class i have it as private but then i have a public function for the linkedlist how do i return everything from this linkedlist from the main file

OpenStudy (mimi_x3):

private LinkedList<Crap> craps; public LinkedList<Crap> getCrapList() { return craps; }

OpenStudy (e.mccormick):

Yes, that is basically what getters let you do. Return information even though it is private. I am not sure where your problem is.

OpenStudy (mimi_x3):

I have a linkedlist of rooms in a hotel class..how do i return all of the rooms within the hotel

OpenStudy (mimi_x3):

I have a class hotel too

OpenStudy (mimi_x3):

In java, i seem to be able to only return one element i.e one room

OpenStudy (mimi_x3):

i want a list of rooms

OpenStudy (e.mccormick):

Then you need a getter that does so. Probably can use the toArray() method.

Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!
Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!