Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static void main(String[] args) {
- test n = new test();
- String hello = "hello";
- System.out.println("Resultaat: " + n.recursie(hello,hello.length()));
- }
- public String recursie(String woord,int l)
- {
- System.out.println(woord + " " + l);
- if(l > 1)
- {
- woord = recursie(woord.substring(0,l-1) + "*" + woord.substring(l-1),l-1);
- }
- return woord;
- }
- /*
- hell*o 4
- hel*l*o 3
- he*l*l*o 2
- h*e*l*l*o 1
- Resultaat: h*e*l*l*o
- */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement