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.

Answer :

frknkrtrn

Answer:

public static List<String> listUpper(List<String> list){

    List<String> upperList = new ArrayList<String>();

   

    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

Other Questions