Question Get Answer

Hi there! I'm stumped on how to make get() method for an Arraylist in Java.


private ArrayList<Shipment> shipmentList = new ArrayList<>();


Say I have the above and need methods in which to add and extract from the array. I'm aware of how to add values manually but stuck as how to actually start it, it's been challenging finding generic examples of that. I understand I'm trying to make a method in which to have the program select the array list and the value within the array index position and pull it.

  

Here is the full class as part of a larger program I'm working on; I don't need any other answers regarding the rest of the class, even just links to some resources to understand how to do this would be great.


Class: ShipmentList

Data Members:

- shipmentList : ArrayList<Shipment>

Method Members:

+ ShipmentList()

+ get(index : int) : Shipment

+ add(shipment : Shipment) : void

+ findShipment(destination : Destination) : int

+ length() : int

+ toString() : String

Why Join Course Hero?

Course Hero has all the homework and study help you need to succeed! We’ve got course-specific notes, study guides, and practice tests along with expert tutors.

  • -

    Study Documents

    Find the best study resources around, tagged to your specific courses. Share your own to gain free Course Hero access.

    Browse Documents
  • -

    Question & Answers

    Get one-on-one homework help from our expert tutors—available online 24/7. Ask your own questions or browse existing Q&A threads. Satisfaction guaranteed!

    Ask a Question
Let our 24/7 Java Programming tutors help you get unstuck! Ask your first question.
A+ icon
Ask Expert Tutors You can ask You can ask You can ask (will expire )
Answers in as fast as 15 minutes