Create a new Java class called StringLab.
Inside the main() method:
Create a String variable with the value: " Welcome to the Java String Lab! ". Use the following methods on this string and print the results: length(): Print the length of the string. charAt(): Print the character at index 7. substring(): Extract and print the word "Java" from the string. toUpperCase() and toLowerCase(): Print both the uppercase and lowercase versions. indexOf(): Find and print the index of the first occurrence of "Java". contains(): Check if the string contains the word "Lab" and print the result. replace(): Replace "Java" with "Java Programming" and print the result. split(): Split the string by spaces and print each word using a for loop. trim(): Trim any leading or trailing spaces and print the result. equals() and equalsIgnoreCase(): Compare the string "java string lab!" with " Welcome to the Java String Lab! " and print the results.
๐ For Loop: Count Vowels Write a for loop to count how many vowels (a, e, i, o, u) are in the original string. Print the result.
๐ While Loop: Check for Palindrome Create a new String variable with a single word (e.g., "racecar").
Use a while loop to check if the word is a palindrome (reads the same forward and backward). Print whether it is or not.
๐ Do...While Loop: Input Validation Prompt the user to enter a sentence.
Use a do...while loop to repeat the prompt until the user types a sentence that contains the word "Java".
Once the condition is met, print "Thank you!".
Create a StringBuilder object initialized with "StringBuilder Lab". Perform the following operations:
append(): Add " - Learning Java" to the StringBuilder. insert(): Insert " is fun" after the word "Lab". delete(): Delete the word "Learning" from the StringBuilder. reverse(): Reverse the entire string and print it.
Create a StringBuffer object initialized with "Multithreading Lab".
Perform the same operations as in Task 3: append() insert() delete() reverse()