Null Cipher | Java program to decode NULL CIPHER ; Function to decode the message . ; Store the decoded string ; found variable is used to tell that the encoded encoded character is found in that particular word . ; Set found variable to false whenever we find whitespace , meaning that encoded character for new word is not found ; Driver Code
class GFG { static String decode ( String str ) { String res = " " ; boolean found = false ; for ( int i = 0 ; i < str . length ( ) ; i ++ ) { if ( str . charAt ( i ) == ' ▁ ' ) { found = false ; continue ; } if ( ! found ) { if ( ( str . charAt ( i ) >= ' A ' && str . charAt ( i ) <= ' Z ' ) || ( str . charAt ( i ) >= ' a ' && str . charAt ( i ) <= ' z ' ) ) { res += Character . toString ( str . charAt ( i ) ) ; found = true ; } } } return res . toLowerCase ( ) ; } public static void main ( String [ ] args ) { String in ; in = " A ▁ Step ▁ by ▁ Step ▁ Guide ▁ for ▁ Placement ▁ Preparation ▁ by ▁ GeeksforGeeks " ; System . out . println ( " Enciphered ▁ Message : ▁ " + decode ( in ) ) ; } }