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
Martha is a network monitoring technician working on a firewall for her company’s network. To filter traffic going through the f
tia_tia [17]

Answer:

D

Explanation:

Not much of a tech person, but protocol then firewall seems the most reasonable.

7 0
3 years ago
Read 2 more answers
Your colleague received an E-mail from a bank that is requesting credit card and PIN number information. Which of the following
uysha [10]

Answer: A) Phishing

Explanation:

Phishing is type of attack in computer field that is processed to hack or steal the data of authorized user.The attacker acts as trusted party and then interacts with the authorized user through email or messages to gain  confidential information like pin code, credit card number, login details etc of that user.

  • According to the question, colleague is experiencing phishing as he has been requested for pin-code and credit-card number from a wrong source behaving as authorized bank.
  • Other options are incorrect because ransomware is attack that asks for ransom from authorized user for reviving their access. on system. Spoofing is falsifying as some other party to receive advantage.
  • Mail poisoning is inclusion of inappropriate details in email such as invalid email address etc.
  • Thus, the correct option is option(A).
0 0
3 years ago
Cloud offers better protection compare to on premise?​
dangina [55]

Why is cloud better than on-premise? Dubbed better than on-premise due to its flexibility, reliability and security, cloud removes the hassle of maintaining and updating systems, allowing you to invest your time, money and resources into fulfilling your core business strategies.

The security of the cloud vs. on-premises is a key consideration in this debate. Cloud security controls have historically been considered less robust than onprem ones, but cloud computing is no longer a new technology. . A company running its own on-premises servers retains more complete control over security.

Believe it!!

Pls follow me.

6 0
3 years ago
A programming language is used to tell a computer what to do to solve a problem?
goldfiish [28.3K]
As far as humans are concerned. What's written in the programming language needs to interpreted or compiled into something that the machine can actually deal with.
5 0
3 years ago
Create a list of consent rules to live by​
Agata [3.3K]
Intercourse
Kiss
Going into someone’s house
4 0
3 years ago
Other questions:
  • What would I need to make the perfect music video
    10·1 answer
  • Which are the best examples of costs that should be considered when creating a project budget?
    11·1 answer
  • What is the output of the following function if the array nums contains the values 1 2 3 4 5 int backwards(int nums[]) { for (x
    15·1 answer
  • Write a c++ program to calculate the approximate value of pi using this series. The program takes an input n that determines the
    13·1 answer
  • An open intersection is one that
    9·2 answers
  • Part of metacognition involves making a plan to address <br> .
    9·2 answers
  • Sometimes we care about the order of a list, and need to reorder the items according to a condition (alphabetical, numerical, et
    11·2 answers
  • This function chooses the screen to display based on the score.What is the correct way to call this function?
    13·2 answers
  • College entrance requirements are the expectations for admission.
    12·1 answer
  • Fill in the blank
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!