Question

When someone tries to add an item to a full container, there are a number of...

When someone tries to add an item to a full container, there are a number of possible outcomes:

  • An exception is thrown
  • An error is displayed on the screen/console
  • The item is not added
  • The array is "expanded" and the item is added (this is how java.util.ArrayList handles this situation)
  • etc

Can you think of any other ways to handle this situation? Make a recommendation for how you think this situation should be handled and briefly explain why.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

One way can do:

When user trying to add to full container than it should ask user to expand the array and add it to the container or ignore the element

This flag can set while creating the container object, if set true than it will expand , if false it will ignore the value

Note : If you like my answer please rate and help me it is very Imp for me

Add a comment
Know the answer?
Add Answer to:
When someone tries to add an item to a full container, there are a number of...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • This is a Java project. It has alot of details T.T The project only uses the CONSOLE! I am looking for many ways to solv...

    This is a Java project. It has alot of details T.T The project only uses the CONSOLE! I am looking for many ways to solve this project so if you have the time, please try it! It means so much!! This is a store management system. It has 3 classes. (Goods, Management, UI)  There should be an array in the Management class contains Goods objects, and there should be a function that manages this array, meaning adding and deleting objects,...

  • Lab 3 – Array-Based Stack and Queue Overview In this assignment, you will be implementing your...

    Lab 3 – Array-Based Stack and Queue Overview In this assignment, you will be implementing your own Array-Based Stack (ABS) and Array-Based Queue (ABQ). A stack is a linear data structure which follows the Last-In, First-Out (LIFO) property. LIFO means that the data most recently added is the first data to be removed. (Imagine a stack of books, or a stack of papers on a desk—the first one to be removed is the last one placed on top.) A queue...

  • !!!!!!!Java!!!!! When you are confident that your methods work properly and that you can generate random...

    !!!!!!!Java!!!!! When you are confident that your methods work properly and that you can generate random text with my generateText method, you can move on to the second step. Create a third class called Generator within the cs1410 package. Make class. This class should have a main method that provides a user interface for random text generation. Your interface should work as follows: Main should bring up an input dialog with which the user can enter the desired analysis level...

  • I need help with Task 1 at the end. most of this is background information. Willowbrook...

    I need help with Task 1 at the end. most of this is background information. Willowbrook School is a small private school that has retained your services as a systems analyst to assist in the development of a new information system for the school’s administrative needs. Background Willowbrook School is a small, private school in the Midwest United States. For the past 20 years, it has offered a curriculum for preschool through 6th grade. Five years ago it expanded to...

  • In this lab, a piece of working software is given. You are asked to make changes...

    In this lab, a piece of working software is given. You are asked to make changes to the software according to some requirement. The scenario in this lab mimics the situation that most old software applications are facing---need to update. When covering inheritance and polymorphism, we introduced a pattern that has three elements: instanceof operator, base pointers, and a collection data structure. In the given code, the collection used is a dynamic array (will change its length automatically) called Vector....

  • Additional code needed: PartA: BurgerOrder class (1 point) Objective: Create a new class that represents an...

    Additional code needed: PartA: BurgerOrder class (1 point) Objective: Create a new class that represents an order at a fast-food burger joint. This class will be used in Part B, when we work with a list of orders. As vou work through this part and Part B, draw a UML diagram of each class in using the UML drawing tool 1) Create a new Lab5TestProject project in Netbeans, right-click on the lab5testproject package and select New>Java Class 2) Call your...

  • Do 5 minutes written presentation and an infographic or a poster: Design a Health Campaign: This...

    Do 5 minutes written presentation and an infographic or a poster: Design a Health Campaign: This assignment gives you the chance to design a strategic intervention for some kind of health issue. This is an opportunity to use your design skills to make a print ad, video spot, or social media campaign. Your media work (video, poster, social media campaign plan with infographic, etc.) must be accompanied by a rationale where you explain your methodology and how the evidence base...

  • Please read the article and answer about questions. You and the Law Business and law are...

    Please read the article and answer about questions. You and the Law Business and law are inseparable. For B-Money, the two predictably merged when he was negotiat- ing a deal for his tracks. At other times, the merger is unpredictable, like when your business faces an unexpected auto accident, product recall, or government regulation change. In either type of situation, when business owners know the law, they can better protect themselves and sometimes even avoid the problems completely. This chapter...

  • Chapter 16 The Tax Is Illegal—Getting the Story Out 1. Is it the TRUTH? 2. Is...

    Chapter 16 The Tax Is Illegal—Getting the Story Out 1. Is it the TRUTH? 2. Is it FAIR to all concerned? 3. Will it build GOODWILL and better FRIENDSHIPS? 4. Will it be BENEFICIAL to all concerned? —The “Four Way Test,” written by Herbert J. Taylor, adopted as creed of Rotary International, 1943 Lunapark was an urbanized township. It used to have farms, but they were all gobbled up with housing developments. The only businesses were nonagricultural manufacturers, offices, and...

  • could you please help me with this problem, also I need a little text so I...

    could you please help me with this problem, also I need a little text so I can understand how you solved the problem? import java.io.File; import java.util.Scanner; /** * This program lists the files in a directory specified by * the user. The user is asked to type in a directory name. * If the name entered by the user is not a directory, a * message is printed and the program ends. */ public class DirectoryList { public static...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT