Convert characters of a string to opposite case | Java program to toggle all characters ; Function to toggle characters ; Driver code
import java . util . * ; class GFG { static char [ ] S = " GeKf @ rGeek $ " . toCharArray ( ) ; static void toggleChars ( ) { for ( int i = 0 ; i < S . length ; i ++ ) { if ( Character . isAlphabetic ( S [ i ] ) ) { S [ i ] ^= ( 1 << 5 ) ; } } } public static void main ( String [ ] args ) { toggleChars ( ) ; System . out . print ( " String ▁ after ▁ toggle ▁ " + "NEW_LINE"); System . out . print ( String . valueOf ( S ) ) ; } }