Question: I am trying to implement and test a method to remove a concert ticket from the wallet class. I keep getting an index out of

 I am trying to implement and test a method to removea concert ticket from the wallet class. I keep getting an index

out of bounds exception error? and could greatly use some help! public

I am trying to implement and test a method to remove a concert ticket from the wallet class. I keep getting an index out of bounds exception error? and could greatly use some help!

public ConcertTicket remove() \{ // Create a ConcertTicket reference variable (DO NOT create a // new ConcertTicket - JUST create the reference variable) ConcertTicket yourTicket; // Use the size variable (which always points at the next empt // slot) to get the last added ConcertTicket from the array: yourTicket = tickets[size-1]; // Set that array slot to null: tickets[size-1]= null; // Decrement the size variable: size = size -1; // Return the Concert Ticket: return yourTicket; \} This it the class ConcertTicket that stores the name of a concert, the price, and the date. - Version: - Fall 2019 - Author: clatulip, mapq java.lang.ArraylndexOutOfBoundsException: Index - 1 out of bounds for length 10 at ConcertTicket.Wallet.remove(Wallet.java:82) at ConcertTicket.WalletTest.testRemove(WalletTest.java:51) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAcc 5/6 tests passed (83.3%) usercode 75ms V ConcertTicket 75ms V WalletTest 75ms testAdd() 32ms testRemove() 36ms testResize() 0.0ms testToString() 4.0ms testGetSize() 1.0ms testGetLength() 2.0ms

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!