Apply capitalization of one string to another I want to take the capitalization of one string and apply it to another.

For example: take Apple and orange and turn that into Orange.

This is the solution I implemented. Is there a more efficient way of doing this?

public static String applyCapitalization(String to, String from) {
    int[] capArray = toCapitalizationArray(to);
    char[] charCap = from.toCharArray();
    for (int i = 0; i &lt; capArray.length; i++) {
        if (capArray[i] == 1) {
            charCap[i] = Character.toUpperCase(charCap[i]);
        } else {
            charCap[i] = Character.toLowerCase(charCap[i]);
        }
    }
    return new String(charCap);
}
private static int[] toCapitalizationArray(String to) {
    int[] arr = new int[to.length()];
    for (int i = 0; i &lt; to.length(); i++) {
        char c = to.toCharArray()[i];
        if (Character.isUpperCase(c)) {
            arr[i] = 1;
        } else {
            arr[i] = 0;
        }
    }
    return arr;
}
We can do this in single traversal rather then two 

for (int i = 0; i &lt; min(apple.length(),orange.length()); i++) {
    if (Character.isUpperCase(apple.toCharArray()[i]) &amp;&amp;
        Character.isLowercase(oranger.toCharArray()[i])){
           orange[i] = Character.toUppercase(oranger.toCharArray()[i]);
    }elseif(Character.isLowerCase(apple.toCharArray()[i]) &amp;&amp; 
            Character.isUppercase(oranger.toCharArray()[i])){
           orange[i] = Character.toLowercase(oranger.toCharArray()[i]);
    }
}