Defanged Version of Internet Protocol Address | Java implementation to find the defanged version of the IP address ; Function to generate a defanged version of IP address . ; Loop to iterate over the characters of the string ; Driver Code
class GFG { static String GeberateDefangIP ( String str ) { String defangIP = " " ; for ( int i = 0 ; i < str . length ( ) ; i ++ ) { char c = str . charAt ( i ) ; if ( c == ' . ' ) { defangIP += " [ . ] " ; } else { defangIP += c ; } } return defangIP ; } public static void main ( String [ ] args ) { String str = "255.100.50.0" ; System . out . println ( GeberateDefangIP ( str ) ) ; } }