2

I know there is a function string.Format() in .NET

Is there an equivalent version available in Java?

1
  • 1
    Did you search for this? Check this might help you. Commented Feb 2, 2012 at 6:04

3 Answers 3

1

Yes, there is also String.format() which supports output ala C printf() since Java 1.5.

String.format(String format, Object... args) 
System.out.format() // alternativ
System.out.printf() // alternativ

javadoc

Sign up to request clarification or add additional context in comments.

Comments

1

Try this:

String format = "Test: {0}, {1}"
System.out.println(MessageFormat.format(format, "Text1", "Text2"))

see this question and answers

Comments

-1

Perhaps not exactly equal but Java does have String.format which provides very similar functionality. You'll find that Java and C# are very similar.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.