When one piece of code invokes or calls a function, it is done by the following syntax: variable = function_name ( args, ...); The function name must match exactly the name of the function in the function prototype. The args are a list of values (or variables containing values) that are "passed" into the function
Answer:
//method listUpper takes a list of strings as parameter
public List<String> listUpper(List<String> list)
{
List<String> finalList= new ArrayList<String>();
//finalList is created which is a list to display the strings in upper case
for(String s:list){ //loop iterates through every string in the list and converts each string to Upper case using toUpperCase() method
s = s.toUpperCase();
finalList.add(s); } //finally the upper case strings are added to the finalList
return finalList; } //return the final list with uppercase strings
Explanation:
The method listUpper() works as follows:
For example we have a list of following strings: ("a", "an", "being").
finalList is a list created which will contains the above strings after converting them to uppercase letters.
For loop moves through each string in the list with these strings ("a", "an", "being"). At each iteration it converts each string in the list to uppercase using toUpperCase() and then add the string after converting to uppercase form to the finalList using add() method. So at first iteration "a" is converted to A and added to finalList, then "an" is converted to uppercase AN and added to finalList and at last iteration "being" is converted to BEING and added to finalList. At the end return statement returns the finalList which now contains all the string from list in uppercase form.
Make the zig zag part more spaced out