Explanation of Solution
Statement to change first lowercase character to uppercase character:
Assume each and every element in list is considered as a StringBuilder, statement to change the first character to uppercase for each element in 1ist using a forEach method is given below:
Statement:
//Use forEach() method
l1.forEach(e -> {
/*Check whether the length of StringBuilder is greater than 0 */
if (((StringBuilder)e).length() > 0) {
/*Declare variable and initialize with "0" index of StringBuilder */
char ch = ((StringBuilder)e).charAt(0);
//Check whether character is lowercase character
if (Character.isLowerCase(ch)) {
/*Change the first lowercase character to uppercase character */
((StringBuilder)e)...
Want to see the full answer?
Check out a sample textbook solutionChapter 20 Solutions
Introduction to Java Programming and Data Structures, Comprehensive Version (11th Edition)
- WAP c# program creates a string, s1, which deliberately leaves space for a name, much like you’d do with a letter you plan to run through a mail merge. We add two to the position where we find the comma to make sure there is a space between the comma and the name.arrow_forwarddef q5(sentence): Assumes sentence is a string. Returns a list of all the words in sentence, where a word is a token separated by white space, (you can use sentence.split()), and then for each word, make it lowercase and remove any character that is not alpha-numeric (a-z or 8-9). For example, I q5("The Plague" (French: "La Peste"), 1947, by Albert CamUs.') should return ['the', 'plague', 'french', 'la', 'peste', '1947', 'by', 'albert', 'camus'] q5('Red@Dragon....ca is great!') should return ['reddragonca', 'is', 'great'] passarrow_forward-Write a statement that assigns the list of seasons of the year to the variable seasons in the following order in Python: Winter Spring Summer Fall -Write one statement that uses the in operator to test if the element 'surfing' is present in list listActivities and print the results. -Using the del keyword and/or the slicing operator:, delete the 3rd through the 5th element from the list listTemps. You've been provided a list named myLst, of six integers. Set the fourth element's value to 7.arrow_forward
- Write a statement, using pyhton language, that creates a two-dimensional list with 5 rows and 3 columns. Then write nested loops that get an integer value from the user for each element in the list.arrow_forwardWhat happens if you try to use an invalid index to access a character in a string?arrow_forwardWrite a program that reads in a line consisting of a student’s name, Social Security number, user ID, and password. The program outputs the string in which all the digits of the Social Security number and all the characters in the password are replaced by x. (The Social Security number is in the form 000-00-0000, and the user ID and the password do not contain any spaces.) Your program should not use the operator [] to access a string element. Use the appropriate functions described in Table 7-1 below. Expression Effect strVar.at(index) Returns the element at the position specified by index strVar[index] Returns the element at the position specified by index strVar.append(n, ch) Appends n copies of ch to strVar, where ch is a char variable or a char constant strVar.append(str) Appends str to strVar strVar.clear() Deletes all the characters in strVar strVar.compare(str) Returns 1 if strVar > str returns 0 if strVar == str; returns −1 if strVar < str…arrow_forward
- Assume the names variable references a list of strings. Write code that determines whether 'Ruby' is in the names list. If it is, display the message 'Hello Ruby'. Otherwise, display the message 'No Ruby'.arrow_forwardI had a list of strings and i want to concatenate them but when I am trying this, I getting error stated cannot perform + operation on string type. The list size is 10.arrow_forwardRead the string variables visitedListName, place1, place2, and place3 from input, assuming that the list's name contains multiple words and each place visited is a single word. The first input line contains the list's name and the second input line contains the places visited. Ex: If the input is: Countries I've visited Qatar Zambia Malta then the output is: Countries I've visited: Qatar Zambia Malta #include <iostream> #include <string> using namespace std; int main() { string visitedListName; string place1; string place2; string place3; /* Your code goes here */ cout << visitedListName << ":" << endl; cout << place1 << endl; cout << place2 << endl; cout << place3 << endl; return 0; }arrow_forward
- Write a statement that will print the first letter of each element of the following list: list1 = [‘Galileo’,‘Oliver’,’Ostwald’,’Descartes’].arrow_forward0 code should form it eklg Basic list structure, python code. Can you explain this while using python 3.10. I would really appreciate it if you can explain how to do it aswell. For this assignment, write a Python script to allow users to enter the following string values: employeeName, employeeSSN*, employeePhone, employeeEmail, and employeeSalary. *(employeeSSN = Employee Social Security Number. For example, 123121234) Once you have entered your values, you should display it in the following format: ---------------------------- Mike Smith ----------------------------- SSN: 123123123 Phone: (111)222-3333 Email: mike@gmail.com Salary: $6000 ----------------------------------------------------------------------------..arrow_forwardWrite a program that reads in a line consisting of a student’s name, Social Security number, user ID, and password. The program outputs the string in which all the digits of the Social Security number, and all the characters in the password are replaced by x. (The Social Security number is in the form 000- 00-0000, and the user ID and the password do not contain any spaces.) Your program should not use the operator [] to access a string element.arrow_forward
- EBK JAVA PROGRAMMINGComputer ScienceISBN:9781337671385Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENT