15

Ahhh yes Prof, because I really want to be doing more work than I need to be...

// Tedious string concatenation.
System.out.println("a: " + a + " b: " + b);

// Output using string formatting.
System.out.printf("a: %d b: %d\n", a, b);

But, hey that's just my opinion.

Comments
  • 2
    but u have to remember all those placeholders...

    For me it depends on if it is worth it (readability vs having to Google the syntax).

    So usually,

    SQL statements, yes,
    just need to append a variable or 2, no
  • 0
    I don't know about Java, but C# has interpolated strings :P

    Kinda the same thing, but nicer
  • 1
    Your example literally took the same amount of characters. Why would it be better?
Add Comment