Question

Pick an interface in the JDK, describe the method(s) that interface requires, and describe a good...

Pick an interface in the JDK, describe the method(s) that interface requires, and describe a good use of it.

Homework Answers

Answer #1
Thanks for the question, Here is one interface List which is inside the java.util package.

================================================================================================

List Interface:

        This interface is an extension of the collection interface. Elements in the List can be inserted, accessed, or deleted by their position in the list, starting from index 0.

        A few methods of this interface include:

        1. add(): This method takes 2 arguments as input, the first one the index at which you want to add the element, and the second one is the element itself. This function will simply add the element at the specified location(index) in the list, and will not return anything.

        2. get(): This method takes 1 argument as input, that is the index at which you want to fetch the element in the list from. And will return the fetched element as output.

        3. indexOf(): This method takes 1 argument as input, that is the element to search for, and will return the index of that element at which it is found in the list if found, and will return -1 otherwise.

        4. lastIndexOf(): This method works pretty much the same as the previous method. The only difference is, if the element is found in the list more than once, the previous method returns the index of the first appearance of the element in the list, whereas, this method returns the index of the last appearance of the element in the list.

        5. remove(): This method takes 1 argument as input, that is the index from which the element to delete in the list, and will return the deleted element as outpu.

        6. subList(): This method takes 2 arguments as input, the start index, and the end index, and will return the list of elements from start index to end index as output.

        7. listIterator(): This method if no parameter is passed as input, returns the iterator, pointing to the start of the list. Whereas if an integer parameter is passed as input, will now return the iterator, pointing to the index specified as input.
Concrete class that implements List interface is ArrayList.

thank you !

Know the answer?
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
Similar Questions
Pick a pair of concrete classes in the JDK in a parent-child relationship and discuss a...
Pick a pair of concrete classes in the JDK in a parent-child relationship and discuss a few polymorphic and/or overloaded methods. Do not use Object as the parent class - it is too trivial to address the issues to be addressed here, and in any case, Object is the final parent of all classes in Java.
Pick a pair of concrete classes in the JDK in a parent-child relationship and discuss a...
Pick a pair of concrete classes in the JDK in a parent-child relationship and discuss a few polymorphic and/or overloaded methods. Do not use Object as the parent class - it is too trivial to address the issues to be addressed here, and in any case, Object is the final parent of all classes in Java.
Pick two of the following methods and briefly describe how they work. For each method that...
Pick two of the following methods and briefly describe how they work. For each method that is chosen, include a description of a research question (real or hypothetical) for each method, and please explain why it why chosen. Be as descriptive as possible Following methods to choose from: functional magnetic resonance imaging (fMRI) transcranial magnetic stimulation (TMS) electroencephalography (EEG) computed tomography (CT) diffusion tensor imaging (DTI)
A good capacity decision requires that it be tightly integrated with the organization's strategy and investments....
A good capacity decision requires that it be tightly integrated with the organization's strategy and investments. But there are other "considerations" to making a good capacity decision. Name them. Describe each in a sentence or two
what does the simplified method requires the use of?
what does the simplified method requires the use of?
When the s-parameters at a 2-port DUT terminal [S]ter have been found, describe the method, with...
When the s-parameters at a 2-port DUT terminal [S]ter have been found, describe the method, with quantitative analysis, to de-embed from [S]ter to the active device terminal [S]dev .
Pick a specific market for a good or service. Examine that market and determine where that...
Pick a specific market for a good or service. Examine that market and determine where that market lies on the spectrum of competition (perfectly competitive - monopoly, and everything in between). Provide the assumptions you use to make that determination. Discuss who the firms are in that market (if possible). From the consumers perspective, is it beneficial that the market is set in that structure?
(JAVA) Create a class that represents a Customer. Use good OO programming technique. A Customer has...
(JAVA) Create a class that represents a Customer. Use good OO programming technique. A Customer has a firstName, lastName, customerNumber, emailAddress. You can add some more fields if you want to, but those 4 are a minimum. Override the equals method, and the toString method from the Object class. Implement the Comparable interface. In the main method, create some instances of the Customer class, and demonstrate the use of the accessor and mutator methods, as well as the compareTo method.
Describe an ethical conflict that one have encountered in the health care arena. Good facts make...
Describe an ethical conflict that one have encountered in the health care arena. Good facts make good ethics, so make sure that one provides a clear-but-brief fact statement of the nature of the ethical conflict and the stakeholders/parties involved. Then, pick one of the following three theories (principle of double effect, deontology, consequentialism) and apply it to the ethical scenario. In applying the chosen theory to the scenario, briefly answer each of the following questions: 1. Describe the ethical conflict....
S&P 500 Please pick one ETF or Mutual Fund that tracks the Standard and Poor 500...
S&P 500 Please pick one ETF or Mutual Fund that tracks the Standard and Poor 500 Index.             What is the name of the fund? Describe its profile             List its top 10 holdings What is its 10-year historical return?             How diversified is it by sectors of the economy? Meaning describe or give the percentage of how much of the fund is invested in each of the sectors of our economy.)