#String Handling Practice by Using String, StringBuilder and StringBuffer
-
WAP to print any given inputString in following format.
Output index: 0 1 2 3 4 chars: H e l l o Every character is seprated by tab, use "\t" for inserting tab.
-
WAP to print substring of a given inputString by using
String substring(int index)
. Accept inputString and index from user. -
WAP to accept inputString from user and replace all the vowels by *, by using
String replace(char oldChar, char newChar)
.String s1 = "vaibhav"; s1 = s1.replace('a','*'); System.out.println(s1); output: v*ibh*v
-
Modify the above program so that:
- first occurred vowel will be replaced by *.
- Second occurred vowel will be replaced by ^.
- Third occurred vowel will be replaced by !.
repeat the above process for all occurred vowels.
-
WAP to replace all the occurrence of given subString from the inputString. --- (search library function for the task from the java docs by using the link [https://docs.oracle.com/en/java/javase/13/docs/api/java.base/java/lang/String.html]).
-
WAP to change case of given inputString to uppercase by using
String toUpperCase()
. -
WAP to print the totalWeight of given inputString.
totalWeight can be calculate by adding *ASCII* value of all the characters. for example: inputString = "Abc"; totalWeight = 65 + 98 + 99; where ASCII values: A --> 65 b --> 98 c --> 99
-
WAP to print UpperWeight of given inputString. UpperWeight can be find by adding all the upper case characters of the inputString.
-
WAP to print AbsoluteWeight of given inputString. Absolute weigth can be calulated as:
absoluteWeight = UpperWeight - LowerWeight; 1. absoluteWeight will always be a positive value. 2. LowerWeight can be find by adding all the lower case characters of the inputString.
-
WAP to print index of given character ch from inputString.
input: char ch = 'a'; String inputString = "vaibhav"; output: 1
-
WAP to print all the index in newline of given character ch form the inputString.
input: char ch = 'a'; String inputString = "vaibhav"; output: 1 5