How can I add a space in between two outputs?
Add a literal space, or a tab:
public void displayCustomerInfo() {
System.out.println(Name + " " + Income);
// or a tab
System.out.println(Name + "\t" + Income);
}
You can use System.out.printf()
like this if you want to get nicely formatted
System.out.printf("%-20s %s\n", Name, Income);
Prints like:
Jaden 100000.0
Angela 70000.0
Bob 10000.0
This format means:
%-20s -> this is the first argument, Name, left justified and padded to 20 spaces.
%s -> this is the second argument, Income, if income is a decimal swap with %f
\n -> new line character
You could also add formatting to the Income argument so that the number is printed as desired
Check out this for a quick reference
System.out.println(Name + " " + Income);
Is that what you mean? That will put a space between the name and the income?