I'm trying to store a string and determine whether it is a uppercase/lowercase letter or number, If the character is a lower case letter, redisplay the character in upper case, if the character is a upper case letter, redisplay the character in lower case if the character is a digit, display it as an asterisk. I could make it with the numbers but if I include .toString().toLowerCase() or .toUpperCase() for the letters the program keeps looping. What should I do?
public class CharacterArray { public static void main(String[] args) { StringBuilder input = new StringBuilder("800 Test St NY"); for (int i = 0; i < input.length(); i++) { System.out.println(input.charAt(i)); if(Character.isDigit(input.charAt(i))){ input.replace(i,i+1,"*"); } else if(Character.isUpperCase(input.charAt(i))) { input.replace(i, i+1,input.toString().toLowerCase()); } else if(Character.isLowerCase(input.charAt(i))) { input.replace(i, i+1,input.toString().toUpperCase()); } System.out.println(input); } } }