GeeksforGeeks » Java specific Questions

programming

(2 posts)

Tags:

  1. mahmoud
    guest
    Posted 7 months ago #

    Write a Java program that outputs all possible strings formed by using the characters 'c', 'a', 'r', 'b', 'o' , and 'n' exactly once.

  2. Ravi
    guest
    Posted 6 months ago #

    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.

RSS feed for this topic