I am trying to print a two column output of words and word count. I seem to be having an issue with the formatting. Here is my line of code for the printf:
public void inOrderTraverseTree(Node focusNode){ if(focusNode != null){ inOrderTraverseTree(focusNode.lChild); //focusNode.visit(); System.out.printf("%-15s %15d", focusNode.key, focusNode.count); inOrderTraverseTree(focusNode.rChild); } } After looking at my output again, it seems that my issue is that the second column follows the length of the word in the first column. Is there a way to set a width for an output so that the count does not depend on the end of the word?