package strings;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

public class StringEncode {

    static String encode(String[] input) {
        List<String> result = new ArrayList<>();
        for (String string : input) {
            result.add(string.replaceAll("\"", "\\\""));
        }
        
        return String.join("\"", result);
    }
    
    static String encode_v2(String[] input) {
        StringBuffer buffer = new StringBuffer();
        
        for (String string : input) {
            buffer.append(string.replaceAll("\"", "\\\"")).append("\"");
        }
        
        return buffer.toString();
    }
    
    public static void main(String[] args) {
        String result = encode(new String[]{"a", "b", "c"});
        String result_2 = encode_v2(new String[]{"a", "b", "c"});
        
        System.out.println(result);
        System.out.println(result_2);
        
        String[] split = result.split("\"");
        
        System.out.println(Arrays.toString(split));
    }
}
