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]
3 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]3 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
Rishilaugh I would like to change my username
allsm [11]

Answer: just text them through their help thing or settings.

Explanation:

3 0
3 years ago
Read 2 more answers
Qbasic program to convert Nepali rupees into paisa​
Svetradugi [14.3K]

Answer:

INPUT "What is the amount of rupees you want converted into paisa"; rupees

paisa = rupees*100

PRINT paisa

Explanation:

done in QBASIC
the semicolon in the 1st line makes the question have a ? at the end. the rupees key word in the 1st line saves the input as a variable

then the second line multiplies by 100 since there are 100 paisa in 1 rupee

5 0
2 years ago
Please Help Fast!!!!!! Brainliest for First to answer!!! Conflict resolution is the process of solving disputes and disagreement
MaRussiya [10]
It's true............
8 0
3 years ago
Tristen is teaching her history course. She printed off her presentation so the students could take notes. Wyatt is
sveta [45]

Since Tristen want her students to take notes on her presentations, she should have some sort of handout.

Because Wyatt, wants to ensure that students who do not have PowerPoint can still view his presentations, converting it into a pdf is best.

Since Reed's students are very visual, converting his slides into a video will make it better for students who want to spend some time assessing some of the graphs or equations.

Thus, A is the best choice.

6 0
3 years ago
Read 2 more answers
Realizar una lista con 200 valores aleatorios entre 140 y 200 en Matplotlib. Graficar la distribución de los datos en un
Airida [17]

hola no conozco el toldo, pero necesito puntos cerebrales tan lo siento

Explanation:

7 0
3 years ago
Other questions:
  • You are reluctant to write an extra credit book report because you are afraid that your language and punctuation skills are not
    11·1 answer
  • Because you do not know every possible future use for the data TerramEarth collects, you have decided to build a system that cap
    15·1 answer
  • If you like to play graphic-intensive games on your computer and you find that your computer can't keep up, you should add a ___
    6·1 answer
  • Ben's team is working on an English project. The members want to see everyone's progress on their part of the project. What tech
    7·2 answers
  • Super easy question but you have to think about it because it’s not that easy I’ll mark brainliest for first answer Explain the
    11·1 answer
  • Can your digital footprint be destroyed or does it remain active on the internet forever
    5·1 answer
  • What service converts ip addresses into more recognizable alphanumeric names??
    8·1 answer
  • Which of the following is a hardware component used to hold the BitLocker encryption key and ensures encrypted data is not acces
    5·1 answer
  • How many lines are on a standard sheet of typing paper?
    8·1 answer
  • Is the most important characteristic of a hard drive.​
    7·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!