The challenge
Complete the solution so that the function will break up camel casing, using a space between words.
Example
solution("camelCasing") == "camel Casing"
Test cases
import org.junit.Test;
import static org.junit.Assert.assertEquals;
import org.junit.runners.JUnit4;
public class SolutionTest {
@Test
public void tests() {
assertEquals( "Incorrect", "camel Casing", Solution.camelCase("camelCasing"));
assertEquals( "Incorrect", "camel Casing Test", Solution.camelCase("camelCasingTest"));
assertEquals( "Incorrect", "camelcasingtest", Solution.camelCase("camelcasingtest"));
}
}
The solution in Java
class Solution {
public static String camelCase(String input) {
String out = "";
for (int i=0; i<input.length(); i++) {
String c = Character.toString(input.charAt(i));
if (c.equals(c.toUpperCase())) {
out+=" ";
}
out+=c;
}
return out;
}
}