Skip to Main Content

Java Programming

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Does System.out.println() has a limit ?

807603Jun 23 2006 — edited Feb 16 2008
I have this little program that permuates strings

public class PermutationGenerator
{
private void perm(String s, String prefix)
{
int length = s.length();

if (length== 0)
System.out.println(prefix);

else
{
for (int i = 0; i < length; i++)
{
perm(s.substring(0, i) + s.substring(i+1, length), prefix + s.charAt(i));
}
}
}

public void printPermutations(String s)
{
perm(s,"");
}


public static void main(String[] args)
{
new PermutationGenerator().printPermutations("word") ;
}

}

The problem is that when I use a longer string like "longword", I only get 299 different permutations printed. Even if I use an "evenlongerword", I will get 299 permutations. Is this because of java? Because I can't see any errors in my code.
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Mar 15 2008
Added on Jun 23 2006
7 comments
738 views