Java - Generate 3 Letter Words

Description

Generate 3 Letter Words

Demo

import java.util.Scanner;

public class Main {

  public static void main(String[] args) {

    @SuppressWarnings("resource")
    String chars = "cat";

    for (int first = 0; first < chars.length(); first++) {
      for (int mid = 0; mid < chars.length(); mid++) {
        for (int last = 0; last < chars.length(); last++) {
          System.out.printf("%c%c%c ", chars.charAt(first),chars.charAt(mid), chars.charAt(last));
        }// end of inner for
      }// end of second for
    }// end of first for
  }// end of main
}// end of class/*from  w  w  w. ja  v a2 s.  c  o  m*/

Related Topic