Skip to content

Instantly share code, notes, and snippets.

@chartsai
Created July 25, 2017 23:42
Show Gist options
  • Save chartsai/793152a1423c31563e74dec048e2be41 to your computer and use it in GitHub Desktop.
Save chartsai/793152a1423c31563e74dec048e2be41 to your computer and use it in GitHub Desktop.
public static void main(String[] args) {
String a = "Charlie123";
StringBuilder sb = new StringBuilder();
for (char c : a.toCharArray()) {
if ('a' <= c && c <= 'z') {
sb.append(String.valueOf(c).toUpperCase());
} else if ('A' <= c && c <= 'Z') {
sb.append(String.valueOf(c).toLowerCase());
} else {
sb.append(c);
}
}
System.out.println(sb.toString());
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment