So I have used this site a good deal, but I can't find an answer... How can I manipulate specific chars/strings from a larger string. I'm trying to use string.substring(pos,amount) but when I try and use it in loops I get a string Index Error. for instance- How could I remove 'e' at [4] from string "abcdefg" or just capitalize "cde"? Sorry for lack of formal code in my question, it's mainly a conceptual thing. Thank you.
Thanks for the suggestions I was trying to answer this question: Write a program that takes as input a string of only letters and displays the string with every third letter capitalized starting with the second letter, and all other letters lower-case.
With this code:
public class Test {
public static void main(String[] arguments){
Scanner fish = new Scanner(System.in);
String a = fish.nextLine();
int len=a.length();
for (int i = 1; i < len; i += 3){
String z = a.substring(i, 1);
String q = a.substring(i + 1);
a = z.toUpperCase() + q;
}
System.out.println(a);
}
}