Ask Question
10 October, 20:10

Write a method called listUpper () that takes in a list of strings, and returns a list of the same length containing the same strings but in all uppercase form. You can either modify the provided list or create a new one.

+4
Answers (1)
  1. 10 October, 20:15
    0
    public static List listUpper (List list) {

    List upperList = new ArrayList ();

    for (String s:list) {

    s = s. toUpperCase ();

    upperList. add (s);

    }

    return upperList;

    }

    Explanation:

    Create a method named listUpper that takes list as a parameter

    Inside the method, initialize a new list named upperList. Create a for-each loop that iterates through the list. Inside the loop, convert each string to uppercase, using toUpperCase method, and add it to the upperList.

    When the loop is done, return the upperList
Know the Answer?
Not Sure About the Answer?
Find an answer to your question 👍 “Write a method called listUpper () that takes in a list of strings, and returns a list of the same length containing the same strings but ...” in 📗 Computers & Technology if the answers seem to be not correct or there’s no answer. Try a smart search to find answers to similar questions.
Search for Other Answers