
All possible words?
1 Expert Answer

Patrick B. answered 06/25/19
Math and computer tutor/teacher
Letters can be repeated.... you are going to need FIVE (5) nested for loops.... for real!!!
Sorry, but it is what it is....
==============================================
class FiveLetterWords
{
// there are 26^5 = 11,881,376 possible words since letters can be repeated
public static void main(String args[])
{
for (int iLoop1= 65; iLoop1<=90; iLoop1++)
{
for (int iLoop2=65; iLoop2<=90; iLoop2++)
{
for (int iLoop3=65; iLoop3<=90; iLoop3++)
{
for (int iLoop4=65; iLoop4<=90; iLoop4++)
{
for (int iLoop5=65; iLoop5<=90; iLoop5++)
{
char [] chArray = new char[5];
chArray[0] = (char)(iLoop1);
chArray[1] = (char)(iLoop2);
chArray[2] = (char)(iLoop3);
chArray[3] = (char)(iLoop4);
chArray[4] = (char)(iLoop5);
String str5 = new String(chArray);
System.out.println(str5);
} //iLoop5
} //iLoop4
} //iLoop3
} //iLoop2
} //iLoop1
} //main
} //class

Patrick B.
Probably would be best on another thread, or redirect the output to file. As stated you have over 11 million character strings to store06/25/19
Still looking for help? Get the right answer, fast.
Get a free answer to a quick problem.
Most questions answered within 4 hours.
OR
Choose an expert and meet online. No packages or subscriptions, pay only for the time you need.
Patrick B.
Also I am using capital letters.... if you want lowercase letters, then per the ASCII table, your for loops start at a=97 and end at z=12206/25/19