I have created a a basic table and am trying to format the tokens in the table to be under the Heading. Here is what I have:
NAME TYPE LINE#
a prod 1
This is what I would like:
NAME TYPE LINE#
a prod 1
I know System.out.printf() would be the ideal way to format my string, but that does not work with my code which is in the main class. I have created an array of Strings and I use the .toString method I have created to print out (a prod 1). Here is my code:
for (int j = 0; j < numOfSym; j++) {
System.out.println(symbols[j].toString());
}
Here is my symbol class:
public class Symbol {
String type;
String name;
int lineNum;
// toString method
public String toString() {
return name + " " + type + " " + Integer.toString(lineNum);
}
}
The String.format does not work either. Would printf() be the best option? Any help or link would be helpful.