0

how to insert String in other string in Android ,I can use getString(R.string.xxx,"insert term")

but in java, how could I do it?

public class const() {
    public static String rawWording = "here is % Text"

    public void main() {
        String text = "java";
        String result = (const.rawWording, text);
    }
}
1
  • 2
    try: String.format("The original %s is tested", "text"); Commented Jul 18, 2019 at 10:57

1 Answer 1

3

You can use String.format like

String output = String.format("%s doe", "John");

For more information and ways, you can refer here

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

4 Comments

linking to another site is not an acceptable answer. at best, may be posted as comment
@SharonBenAsher, My intention is that the respective user should study all the ways we can used String.format method for his better understanding. Just providing answer to his problem is not a good approach (My Opinion). Your thoughts are welcome too.
Please see: Are answers that just contain links elsewhere really “good answers”? Your answer is in another castle: when is an answer not an answer?. In short, answers should always be able to stay on their own, even if linked resource will disappear. Links are great as additional resource, but they can't be only/main content of an answer.
Thanks Pshemo & Sharon. I'll consider you points. :)... Updated my answer.

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.