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]
2 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]2 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
What is one property of a good hash code?
larisa [96]

Answer:- Major property of a good hash code is that objects which are equal should return the same hash code .

Explanation: Hash codes is a numeric value which  is used for identify a object while a equality testing .Hash code can occupy the value of any length and then returns a fixed length value. The value of hash codes are variable.

If two objects are equal then by the method of equal(object) if the hashcode() function is called on both the objects , they produce the same value.

8 0
3 years ago
In a non-formatted/standard template, if the number 25 is converted to text format, the
goldfiish [28.3K]
<h2>The alignment of the text will be "left" by default</h2>

Explanation:

  • In Excel or spreadsheet, if any number is entered, it will automatically be aligned to right because right alignment is preferable for the numbers.
  • In case of any alignment is mentioned in the cell in prior to entering text or if the type of data is changed after or before entering the text, then the text is aligned accordingly.
  • According to the given scenario, a number "25" is entered and it is converted to text. So a text format will preserve the alignment as entered. By default it will be "left" aligned.

3 0
2 years ago
Explain the two filter options available when filtering by a column
dexar [7]
Can you prove more information?
8 0
2 years ago
Read 2 more answers
Inputting a range of numbers comprising a batch and then inputting each serially numbered document is characteristic of the cont
Fynjy0 [20]

Answer:

batch sequence check.

Explanation:

A batch sequence check can be defined as a strategic and systematic control plan which typically involves the process of inputting a range of numbers comprising a batch and then inputting each serially numbered document.

The steps for checking an event data within a batch using a batch sequence check include the following;

I. You'll enter a range of serial numbers of the document in a batch.

II. You'll enter each serially pre-numbered document one after the other.

III. The input documents are sorted by a computer into a serial (numerical) order, match the sequence number range against the input documents, and then reports any part of the document that is missing, a duplicate and out of range.

6 0
3 years ago
Describe how you can use JavaScript to simulate the behavior of the placeholder attribute in older browsers
kirza4 [7]

JavaScript can be used to simulate the behavior of the placeholder attribute in older browsers by using the placeholder attribute which add a placeholder text as a default value and using a different color to differentiate from a color previously entered.

<h3>How are behavior simulated?</h3>

Normally, a user can simulate the behavior of placeholder text in older browsers by setting the value of the value property.

In conclusion, the JavaScript can be used to simulate the behavior of the placeholder attribute in older browsers by using the placeholder attribute which add a placeholder text as a default value and using a different color to differentiate from a color previously entered.

Raed more about JavaScript

<em>brainly.com/question/16698901</em>

6 0
2 years ago
Other questions:
  • What is a bus master?
    14·1 answer
  • A(n) _____ bus enables the central processing unit (CPU) to communicate with a system’s primary storage.
    5·1 answer
  • Is a network where connected devices are located within the same building.
    5·2 answers
  • Which type of microscope can only be used to view non-living specimens?
    10·2 answers
  • A(n) _____ is a firm that delivers a software application, or access to an application, by charging a usage or subscription fee.
    6·1 answer
  • Portable Document Format (PDF) is a file format that provides an electronic image of a document and can be viewed, printed, and
    12·2 answers
  • List three ways of breaking a copyright law with the illegal copy of software.​
    11·1 answer
  • at the grocery store alexa by 1 1/3 lb of ground turkey nasha by two times as much ground turkey is alexa how much ground turkey
    9·1 answer
  • What does Stand for in web design
    9·1 answer
  • Molly needs to access a setting in microsoft windows group policy to change the type of a network to which a computer is attache
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!