0

I am trying to format this text:

Text1                1.00
Other text           -12.12
Something            0.20

into this:

Text1                1.00
Other text         -12.12
Something            0.20

How should I change the code I am using for this format for it to always align perfectly on right?

 public interface BillPrinter {
    
String format(String text, double price);
    
void printLine(String text, double price);
    
default String defaultFormat(String text, double price) {
        return String.format("%-15s      %,.2f", text, price);
    }
}

I have looked at the solutions provided but the -12.12 is never aligned with the others.

0 Answers0