PPK(outdated)
return s.substring(0, pos) + c + s.substring(pos + 1);}
4. Calculate the number of words that start with “a”
int count = 0;
if (s.startsWith("a")) {
count++;}
for(int i = 1; i < s.length(); i++) {
if(s.charAt(i)=='a' && s.charAt(i-1)==' '){
count++;}}
System.out.println(count);}}
5. Palindrome check
String s = "string";
String s1 = "";
String s2 = "";
for (int i = 0; i < s.length(); i++) {
if (s.charAt(i) != ' ') {
s1 += s.charAt(i);}}
System.out.println(s1);
for (int i = s1.length() - 1; i >= 0; i--) {
s2 += s1.charAt(i);}
System.out.println(s2);