Created
November 2, 2012 07:03
-
-
Save TabsPH/3999175 to your computer and use it in GitHub Desktop.
String Permutation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Anagram { | |
public static void main(String[] args) { | |
performedPermutation( "", "Java" ); | |
} | |
public static void performedPermutation( String start, String end ) { | |
if( end.length() == 0 ) | |
System.out.println( start.concat( end ) ); | |
else { | |
for( int i=0; i<end.length(); i++ ){ | |
String tmp = end.substring( 0, i ) + end.substring( i+1 ); | |
performedPermutation( start + end.charAt(i), tmp ); | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment