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
mihalych1998 [28]
3 years ago
12

Write a method called findNames that meets the following specs: It takes two arguments: a list of strings, allNames, and a strin

g, wanted Creates and returns a new list containing only the strings from, allNames, that contain the name stored in wanted as a substring. List allNames should remain unmodified: do not delete, or modify the names in it. This should work in a case insensitive manner, but the names in your result list should be exactly as they are in A (i.e. not converted to lower case). We referred to allames and what the method retums as 'lists', but you are free to represent cach one of them however you want: array or ArrayList. No error checking needed. Example behavior: if allNames is: ["Bob Smith", "Elroy Jetson", "Christina Johnson", "Rachael Baker", "Chris Conly"] and wanted is "cHRis" the resulting list, should be: ["christina Johnson", "Chris Conly"] because only those two strings contain "chris"
Computers and Technology
1 answer:
Anna11 [10]3 years ago
8 0

Answer:

public class Solution {

   public static void main(String args[]) {

       String[] allNames = new String[]{"Bob Smith", "Elroy Jetson", "Christina Johnson", "Rachael Baker", "cHRis", "Chris Conly"};

       String searchString = "cHRis";

       

       findNames(allNames, searchString);

   }

   

   public static void findNames(String[] listOfName, String nameToFind){

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

       

       for(String name : listOfName){

           if (name.toLowerCase().contains(nameToFind.toLowerCase())){

               resultName.add(name);

           }

       }

       

       for(String result : resultName){

           System.out.println(result);

       }

   }

}

Explanation:

The class was created called Solution. The second line define the main function. Inside the main function; we initialized and assign an array called allNames to hold the list of all name. Then a String called searchString was also defined. The searchString is the string to search for in each element of allNames array. The two variables (allNames and searchString) are passed as argument to the findNames method when it is called.

The method findNames is defined and it accept two parameters, an array containing list of names and the name to search for.

Inside the findNames method, we initialized and assigned an ArrayList called resultName. The resultName variable is to hold list of element found that contain the searchString.

The first for-loop goes through the elements in the allNames array and compare it with the searchString. If any element is found containing the searchString; it is added to the resultName variable.

The second for-loop goes through the elements of the resultName array and output it. The output is empty if no element was found added to the resultName variable.

During comparison, the both string were converted to lower case before the comparison because same lowercase character does not equal same uppercase character. For instance 'A' is not same as 'a'.

You might be interested in
How does accenture generate value for clients through agile and devops?
Tomtit [17]

Through quicker time to market, better quality products, and higher customer satisfaction Agile and DevOps are key components of Accenture's value creation for clients.

Accenture plc is a Dublin-based, Irish-American professional services firm with a focus on information technology (IT) services and consulting. It was listed on the Fortune Global 500 and recorded $61.6 billion in revenue in 2022. 91 of the Fortune Global 100 and more than 75 percent of the Fortune Global 500 are among Accenture's current clients.

When General Electric wanted to install a computer at Appliance Park in Louisville, Kentucky, in the early 1950s, Accenture conducted a feasibility study for the company. This study led to GE installing a UNIVAC I computer and printer, which is thought to be the first commercial use of a computer in the United States.  A post was held by Joseph Glickauf, a pioneer in computer consulting.

To know more about Accenture click here:

brainly.com/question/24302004

#SPJ4

4 0
1 year ago
What would happen to life on earth if the ozeon layer was not present?
labwork [276]
People would get skin cancer very easily, plants would start to die off, water would start to evaporate, and the world would be in danger.
6 0
2 years ago
Read 2 more answers
Which of the following is a characteristic of the college savings plan
Hoochie [10]

add the choices please

8 0
3 years ago
Read 2 more answers
"As part of integrating your solution your client indicates that they have certain technologies enabled on their network that al
erastovalidia [21]

Answer:

quality of service

Explanation:

6 0
3 years ago
22. A user receives an error message when logging into Salesforce. What is the first check performed by an administrator?
WARRIOR [948]

Answer:

The first check performed by an administrator that it  View the login history.

Explanation:

When user logging into Salesforce it receives an error message into the  screen it view the logging detail which help us take to troubleshoot the problem. The logging history keeps track information like  who is access the system last time ,date etc .login history  also display up to 20,000 records of user logins for the last six months.

4 0
3 years ago
Other questions:
  • When was unicode invented?
    13·1 answer
  • A site structure that contains multiple links to individual pages, allowing visitors to go through multiple paths to the site is
    9·1 answer
  • All linear programming problems have all of the following properties EXCEPT
    9·2 answers
  • ___MSDS provides information on how to handle, store, discard and care for potentially hazardous chemicals. true or false?​
    5·1 answer
  • What is the by stander effect
    9·1 answer
  • What is "mob of the dead"?
    7·1 answer
  • A gui allows you to interact with objects on the screen such as icons and buttons true or false
    7·1 answer
  • Database accessibility DBA writes subschema to decide the accessibility of database.
    13·2 answers
  • A friend asks you to look over the code for an adventure game and help figure out why it won’t work. Which of these options is s
    5·2 answers
  • How do I find unwanted programs on my computer?
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!