0

Here is my code so far and i`m editing it and adding some code, is there some one might tell me that this is the right way of coding list in permutation.

This program is not yet complete.

package man;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.LinkedList;

public class ScrambleWord {
	
	public static void main(String []args)throws IOException{
		
		LinkedList scrambleList = new LinkedList();
		
        String str;
        
        for(int counter=1; counter<=3; counter++){
			scrambleList.add(new String(str));
			str = str+2;
			
        System.out.println("Enter a Word:");
        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
        str=br.readLine();
        System.out.println("Permutations are :");
        permute("", str);
        str=br.readLine();
        System.out.println("The First Item in the List is");
        }
    }

  public static void permute(String beginningString, String endingString) {
    if (endingString.length() <= 1)
      System.out.println(beginningString + endingString);
    else
      for (int i = 0; i < endingString.length(); i++) {
        try {
          String newString = endingString.substring(0, i) + endingString.substring(i + 1);

          permute(beginningString + endingString.charAt(i), newString);
        } catch (StringIndexOutOfBoundsException exception) {
          exception.printStackTrace();
        }
        
        
      }
  }
		
		
		
	}
2
Contributors
1
Reply
2
Views
6 Years
Discussion Span
Last Post by NormR1
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.