This work I got from my teacher I'd love to residents I worked on it for a week Write a recursive method signature it - public void printSubs (String s) - method parameter in string s. The method prints all letters you can build words of s, each length (from one hundred to all the letters) when the order of the letters in words have to be like their arrangement in s. For example, if s = "bye" method prints the following strings: "B", "y", "e", "by", "ye", "be", "bye" If s = "home" system prints the following strings: "H", "o", "m", "e", "ho", "om", "me", "hm", "he", "oe", "hom", "ome", "hme "," hoe "," home "
This is what I wrote:
private String printSubs(String s, String a) { if(s.length()==0) { return a+""; } return printSubs(s.substring(1), a+s.substring(0,1)) + ", " + printSubs(s.substring(1), a); } The result:
bye, by, be, b, ye, y, e,