Created
July 25, 2017 23:42
-
-
Save chartsai/793152a1423c31563e74dec048e2be41 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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