MCPcopy Create free account
hub / github.com/codemistic/Data-Structures-and-Algorithms / swap

Method swap

Java/Recursion/Permutation.java:3–10  ·  view source on GitHub ↗
(String mystring, int i, int j)

Source from the content-addressed store, hash-verified

1import java.util.*;
2class Permutation {
3 static String swap(String mystring, int i, int j) // function to swap the characters in the string
4 {
5 char ch[] = mystring.toCharArray();
6 char tempo = ch[i];
7 ch[i] = ch[j];
8 ch[j] = tempo;
9 return String.valueOf(ch);
10 }
11 static void permutation(String s, int index) // To permuatate the string
12 {
13 if (index == s.length() - 1) // if the index equals the length, print the string

Callers 1

permutationMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected