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
Which of the following best describes a situation where software should be upgraded instead of replaced? A three-year-old laptop
Ksju [112]
The only option regarding software is the one about the six month old computer that needs more RAM.
4 0
4 years ago
Which action does not happen in each iteration of the repeat loop in the
iren2701 [21]

B. The number of sharks decreases. Explanation: hope it's help i learned about it and you too

7 0
3 years ago
Byte pair encoding is a data encoding technique. The encoding algorithm looks for pairs of characters that appear in the string
erica [24]

Answer:

C. Byte pair encoding is an example of a lossless transformation because an encoded string can be restored to its original version.

Explanation:

Byte pair encoding is a form of encoding in which the most common pairs of consecutive bytes of data are replaced by a single byte which does not occur within the set of data.

For example, if we has a string ZZaaAb, it can be encoded if the pairs of string ZZ are replaced by X and the second pair by Y. So, our data now becomes XYAb.

To get our original data, that is decode it, we just replace the data with the keys X = ZZ and Y = aa thus allowing our original data to be restored.

Since our original string is restored without loss of data, it implies that <u>byte pair encoding is an example of a lossless transformation because an encoded string can be restored to its original version.</u>

8 0
3 years ago
Use sample program from called getopt.c (provided below)
GREYUIT [131]
Beasts shush shrub Nehru need Brid Nehru
6 0
4 years ago
Brianna is feeling overwhelmed by the amount of digital
SIZIF [17.4K]

Information literacy defines the ability to indentify, gather and make good use of available information in to solve problems and increase productivity. Being able to decipher between factual and reliable information can be developed through critical consumption.

The size and amount of available information is so enormous, however, a sizeable amount of these information are not reliable and usually misleading.

Critical consumption allows individuals understand which of the information they require needs are true or untrue.

Hence, Brianna needs to develop her critical consumption skill in other to discern which of the information he needs.

Learn more :brainly.com/question/25284700

4 0
3 years ago
Other questions:
  • Mail merge can be used in business to complete which of the following tasks
    15·2 answers
  • What problem does chlorofluorocarbon (CFC) create?
    5·1 answer
  • Diane is receiving a lot of unwanted e-mail. What steps can she take to reduce the amount of e-mail she receives?
    12·1 answer
  • From what location are the 1st computer instructions available on boot up?
    10·2 answers
  • A Color class has three public, integer-returning accessor methods: getRed, getGreen, and getBlue, and three protected, void-ret
    14·1 answer
  • Any device that uses light to read and write information.
    9·2 answers
  • 2.5 code practice
    12·1 answer
  • Inputs and outputs that allow a user to interact<br> with a piece of software
    14·2 answers
  • Database policies should be created and implemented by all organizations, regardless of the ________ of the organization.
    10·1 answer
  • Daily IT Question
    13·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!