1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Zigmanuir [339]
4 years ago
10

Create an ArrayList of strings to store the names of celebrities and athletes. Add 5 names to the list. Process the list with a

for loop and the get() method to display the names, one name per line. Pass the list to a void method. Inside the method, insert another name at Index 2 and remove the name at index 4. Use a Foreach loop to display the arraylist again, all names on one line separated by asterisks. After the method call in main, create an iterator for the arraylist and use it to display the list one more time.

Computers and Technology
1 answer:
mr Goodwill [35]4 years ago
7 0

Answer:

// ArrayList class is imported

import java.util.ArrayList;

// Iterator class is imported

import java.util.Iterator;

// Main class is defined

class Main {

   // main method to begin program execution

   public static void main(String args[]) {

       // names ArrayList of String is defined

       ArrayList<String> names = new ArrayList<>();

       // 5 names are added to the list

       names.add("John");

       names.add("Jonny");

       names.add("James");

       names.add("Joe");

       names.add("Jolly");

       // for loop to print the names inside the arraylist

       for(int index = 0; index <names.size(); index++){

         System.out.println(names.get(index));

       }

       

       // A blank line is printed

       System.out.println();

       // A newMethod is called with names as argument

       newMethod(names);

       // A blank line is printed

       System.out.println();

       // Instance of Iterator class is created on names

       Iterator<String> iter

           = names.iterator();

 

       // Displaying the names after iterating

       // through the list

       while (iter.hasNext()) {

           System.out.println(iter.next());

       }

   }

   // the newmethod is created here

   public static void newMethod(ArrayList<String> inputArray){

     // A new name is added at index 2

     inputArray.add(2, "Smith");

     // the name in index 4 is removed

     inputArray.remove(4);

     // for each is used to loop the list and print

     for (String name : inputArray) {

       System.out.println(name);

       }

   }

}

Explanation:

The code is well commented. An output image is attached.

You might be interested in
List the five parts of a system.describe them.
dem82 [27]
The five main parts of a system are: 

1. The CPU
The CPU is the brain of the computer. It is the main part that does all th thinking and processing.

2. RAM
which stands for Random Access Memory. As implied in its name, it can be accessed at random times by the CPU. When you open a program, all the scripts and codes that are running need to be run of a separate memory bank. Thus, the RAM takes part.

3. Drives
Hard Drives, SSDs, USB Drives, and SD cards are all forms of main computer memory. That is where the computer stores the OS, your files, and its instructions.

4. Inputs/Outputs
By inputs and outputs i mean hardware, like Speakers (ouput), Monitors (output), Keyboard (input), and Mouse (input).

5. OS
The OS is the Operating System (e.g. Windows, Linux, Mac), which is the main instructions for the computer. It is what makes your computer usable.
3 0
3 years ago
How to make a negative number positive in excel
Viefleur [7K]

Answer:

DB * -1

Explanation:

Use this formula: DB * -1

DB = Desired Box

DB * -1

4 0
3 years ago
Tony is in charge of all presentations for a Fortune 500 pharmaceutical company. In addition to creating powerful and persuasive
Ludmilka [50]

Tony uses the Document Inspector dialog box to <u>remove confidential company information</u> from the presentation.

Explanation:

Document Inspector dialogue box has come as boon to the presentation and office document makers. This saves them from any discrepancies’ regarding revealing any sensitive information, unwanted information, hidden data’s etc.

These information’s if released can be a matter of concern for the employee as well as an organisation. Document inspector prevents an employee from later embarrassment and any legal troubles arising out of his actions.

Hence, Tony who is in charge of Fortune 500 pharma company decided to use Document Inspector dialogue box to make sure that his presentation his complete in all aspects of professionalism and is bereft of any sensitive and unwarranted information.  

5 0
3 years ago
"open workbench can exchange files with microsoft project by importing and exporting the data in ____ file format."
Leviafan [203]
I believe the answer to this question is XML
5 0
3 years ago
Imagine that you work for a media company, TalentScout. Your job is to find a host for a new web-based reality show that will be
Paha777 [63]

hes gay,shes furry

BOOM

spray with ak-47

you just got your self a double kill 2x points 3x damage multiplyer

ROUND WON

gg ez

3 0
3 years ago
Read 2 more answers
Other questions:
  • The IT department in a company is looking for a solution to consolidate the functionality of several mission critical server com
    14·1 answer
  • Which of the following statements about arrays are true?
    10·1 answer
  • The Middle East links which two countries
    10·2 answers
  • In the terms of OOP, in the microwave system, current time is a BLANK and change heat is a BLANK
    15·1 answer
  • Int [] val = { 3, 10, 44 };
    13·1 answer
  • Pls help I will give points
    7·1 answer
  • What is extraction, transformation, and loading? Group of answer choices It is a process of entering data, tracking data, and lo
    5·1 answer
  • Took some photos today for photography class what do you think??
    13·2 answers
  • PLZ HELP!! How does HTML help solve the problem of telling a computer what a web page looks like, not just the content that is o
    15·1 answer
  • Choose the missing words in the code below.
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!