Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
236 views
in Technique[技术] by (71.8m points)

java - How can I add a space in between two outputs?

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
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Add a literal space, or a tab:

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

    // or a tab
    System.out.println(Name + "" + Income);
}

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...