Question: I need to print a String letter by letter with a \* between each letter.
I want to find a recursive solution and not an iterative one. The signature must be :

```java
public static String allStar(String a);

```

Answer: 
Beshambher's answer is a neat and easy way to do it. But if you want to do it recursively then :

```java
public static String allStar(String a) {
    if(a == null || a.isEmpty()) {        
        return "";
    }

    if(a.length() == 1) {
        return a;
    }        
    return  a.charAt(0) + "*" + allStar(a.substring(1));
}

```
Solution for recursive **print** a string

```
public static void allStar(String a) {
    if (a != null && !a.isEmpty()) {
        System.out.print(a.charAt(0));
        if (a.length() > 1) {
            System.out.print('*');
            allStar(a.substring(1));
        }
    }
}

```

Solution for recursive **build** a string

```
public static void allStar(String a, StringBuilder builder) {
    if (a != null && !a.isEmpty()) {
        builder.append(a.charAt(0));
        if (a.length() > 1) {
            builder.append('*');
            allStar(a.substring(1), builder);
        }
    }
}

```

For reducing heap pollution, this one is the *best* for recursive string **build**

```
public static void allStar(String a, int position, StringBuilder builder) {
    if (a != null && position < a.length()) {
        builder.append(a.charAt(position));
        if (++position < a.length()) builder.append('*');
        allStar(a, position, builder);
    }
}

```

Use this for print recursivly builded string

```
public static void main(String[] args) {
    StringBuilder builder = new StringBuilder();
    allStar("test", 0, builder);
    System.out.print(builder);
}

```

Solution with recursions not recommended, but possible for this task.