Function to copy string ( Iterative and Recursive ) | Iterative Java Program to copy one String to another . ; Function to copy one string to other assuming that other string has enough space . ; Driver code
class GFG { static void myCopy ( char s1 [ ] , char s2 [ ] ) { int i = 0 ; for ( i = 0 ; i < s1 . length ; i ++ ) s2 [ i ] = s1 [ i ] ; } public static void main ( String [ ] args ) { char s1 [ ] = " GEEKSFORGEEKS " . toCharArray ( ) ; char s2 [ ] = new char [ s1 . length ] ; myCopy ( s1 , s2 ) ; System . out . println ( String . valueOf ( s2 ) ) ; } }