GeeksforGeeks » Java specific Questions
programming
(2 posts)-
Write a Java program that outputs all possible strings formed by using the characters 'c', 'a', 'r', 'b', 'o' , and 'n' exactly once.
-
public class GenerateString {
public static void main(String[] args) {
char str[]={'E','x','a'};
char as[]=new char[3];
for (int i = 0; i < 3; i++) {
as[0]=str[i];
for (int j = 0; j < 3; j++) {
if(j!=i){
as[1]=str[j];
for (int k = 0; k < 3; k++) {
if(k!=j && k!=i){
as[2]=str[k];
System.out.println(as);
}
}
}
}
}}
}
Reply
You must log in to post.