Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I add a space in between two outputs?

Tags:

java

This is the code I am working with.

public void displayCustomerInfo() {
    System.out.println(Name + Income);
}

I use a separate main method with this code to call the method above:

first.displayCustomerInfo();
second.displayCustomerInfo();
third.displayCustomerInfo();

Is there a way to easily add spaces between the outputs? This is what it currently looks like:

Jaden100000.0
Angela70000.0
Bob10000.0
like image 209
cbass0 Avatar asked Oct 16 '13 00:10

cbass0


People also ask

How do you give a space in output?

The simplest way to properly space your output in Java is by adding manual spacing. For instance, to output three different integers, "i," "j" and "k," with a space between each integer, use the following code: System. out.

How do you add a space in system out Println?

"\t" format specifier is used in println() function to leave tab space in the console.

How do you add a space in python output?

We add space in string in python by using rjust(), ljust(), center() method. To add space between variables in python we can use print() and list the variables separate them by using a comma or by using the format() function.

How do you add a line space in Java?

In Windows, a new line is denoted using “\r\n”, sometimes called a Carriage Return and Line Feed, or CRLF. Adding a new line in Java is as simple as including “\n” , “\r”, or “\r\n” at the end of our string.


1 Answers

Add a literal space, or a tab:

public void displayCustomerInfo() {
    System.out.println(Name + " " + Income);

    // or a tab
    System.out.println(Name + "\t" + Income);
}
like image 129
hexacyanide Avatar answered Sep 30 '22 06:09

hexacyanide