public class TestPad {
public static void main(String[] args) {
String a = "rahul";
for (int i = 1; i <= a.length(); i++) {
print("", a, i);
}
}
public static void print(String prefix, String remaining, int size) {
if (size == 0) {
// We have found the desired length word
System.out.println(prefix);
return;
}
if(remaining.length() == 0) {
return;
}
print(prefix + remaining.charAt(0), remaining.substring(1), size - 1);
print(prefix, remaining.substring(1), size);
}
}
Be the first to comment
You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.