The String Class:
1a.) Given the following delcaration:
String modification1;
Write a statement that stores the uppercase equivalent of the string object called "city" in modification1.
1b.) Write a statement that declares a String variable named city. The variable should be initialized with the string literal "Los Angeles".
1c.) Given the following declaration:
int stringSize;
Write a statement that stores the length of the string object called "city" in stringSize.
1d.) Given the following declaration:
char oneChar;
Write a statement that stores the third character of the string object called "city" in oneChar.
1e.) Given the following delcaration:
String modification2;
Write a statement that replaces all the characters 'e' by # in the string object 'city', and stores the modified string in the modification2.
1f.) Given the following delcaration:
String modification3;
Write a statement that stores the lowercase equivalent of the string object 'city' in modification3.
1.a:
modification1 = city.toUpperCase();
1.b:
String city = "Los Angeles"
1.c:
//to get size we can use length() method
stringSize = city.length();
1.d:
oneChar = city.charAt(2);
// 3rd will be stores at index 2 as indexes starts from 0
1.e:
modification2= city.replaceAll("e","#");
1.f:
modification3 = city.toLowerCase();
NOTE : PLEASE COMMENT BELOW IF YOU HAVE CONCERNS.
I AM HERE TO HELP YOUIF YOU LIKE MY ANSWER PLEASE RATE AND HELP ME
IT IS VERY IMP FOR ME
Get Answers For Free
Most questions answered within 1 hours.