Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class StringLib {
- public static void combine(String str){
- int length=str.length();
- StringBuffer output=new StringBuffer(length);
- combination(str,length,output,0);
- }
- static void combination(String str, int length, StringBuffer output, int src){
- /* show arms-length recursion style with better peformance */
- if (src==length)
- return;
- else{
- for(int i=src;i<length;i++){
- output.append(str.charAt(i));
- System.out.println(output.toString());
- //if (i<length-1)
- combination(str,length,output,i+1);
- output.deleteCharAt(output.length()-1);
- }
- }
- }
- public static void main(String[] args){
- combine("abc");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement