Search...
FAQs
Subscribe
Pie
FAQs
Recent topics
Flagged topics
Hot topics
Best topics
Search...
Search within Beginning Java
Search Coderanch
Advance search
Google search
Register / Login
Post Reply
Bookmark Topic
Watch Topic
New Topic
programming forums
Java
Mobile
Certification
Databases
Caching
Books
Engineering
Micro Controllers
OS
Languages
Paradigms
IDEs
Build Tools
Frameworks
Application Servers
Open Source
This Site
Careers
Other
Pie Elite
all forums
this forum made possible by our volunteer staff, including ...
Marshals:
Campbell Ritchie
Jeanne Boyarsky
Ron McLeod
Paul Clapham
Liutauras Vilda
Sheriffs:
paul wheaton
Rob Spoor
Devaka Cooray
Saloon Keepers:
Stephan van Hulst
Tim Holloway
Carey Brown
Frits Walraven
Tim Moores
Bartenders:
Mikalai Zaikin
Forum:
Beginning Java
A function in Java like string.Format("He is {0}","John") in .NET
Nguyen Minh Duc
Greenhorn
Posts: 2
posted 18 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
I want a function in
Java
like
string.Format("He is {0}",John) in .NET
And the output is "He is John".
Please help me.
Thanks.
I love Java
Christophe Verré
Sheriff
Posts: 14691
16
I like...
posted 18 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
In Java 1.5 has a Formatter class. PrintStream also has a printf method.
And the
String
class also has format method, which would do the same.
The format is a bit different though. Not {0}, but C-like stuff. %s, %d, etc...
[ February 01, 2006: Message edited by: Satou kurinosuke ]
[My Blog]
All roads lead to JavaRanch
Ernest Friedman-Hill
author and iconoclast
Posts: 24207
46
I like...
posted 18 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
See java.text.MessageFormat. In Java 5 (JDK 1.5), your example would be
MessageFormat.format("He is {0}", "John");
[Jess in Action]
[AskingGoodQuestions]
Christophe Verré
Sheriff
Posts: 14691
16
I like...
posted 18 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
MessageFormat ! Didn't know that one. Thanks
[My Blog]
All roads lead to JavaRanch
I am Arthur, King of the Britons. And this is a tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
reply
Bookmark Topic
Watch Topic
New Topic
Boost this thread!
Similar Threads
Collection resources
Java Software Devlopers needed Jr/Mid Lvl
Mouse shift event coding - to trigger a predetermined sequence of images to a GUI
Custom Strings
regex bug
More...